안녕하세요
유니티 2D 프로젝트 만들고 진행하다가 캐릭터가 도중에 멈추는 현상이 발생해서 프로젝트를 갈아 새로 만든 적이 있습니다
그런데 새로 만든 프로젝트에서도 동일한 현상이 발생하여 구글링을 하여 오류를 찾으려고 했지만, 저와 비슷한 문제를 가진 분들이 많이 계신 것을 확인하고
몇 가지 방법을 실행했지만 오류가 지속적으로 발생하여 질문드려요
진짜 미처 화병 날 지경입니다 도와주세요
--
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | cusing System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMove2 : MonoBehaviour { private float maxSpeed = 4.5f; private float jumpPower = 15f; private Rigidbody2D rigid; private SpriteRenderer spriteRender; private Animator anim; private void Awake() { rigid = GetComponent<Rigidbody2D>(); spriteRender = GetComponent<SpriteRenderer>(); anim = GetComponent<Animator>(); } private void Update() { // Jump if (Input.GetButtonDown("Jump") && !anim.GetBool("isJumping")) { rigid.AddForce(Vector2.up * jumpPower, ForceMode2D.Impulse); anim.SetBool("isJumping", true); } // Stop Speed if (Input.GetButtonUp("Horizontal")) { rigid.velocity = new Vector2(rigid.velocity.normalized.x * 0.5f, rigid.velocity.y); } // Direction Sprite if (Input.GetButton("Horizontal")) { spriteRender.flipX = Input.GetAxisRaw("Horizontal") == -1; } // Running Animation if (Mathf.Abs(rigid.velocity.x) < 0.3) { anim.SetBool("isRunning", false); } else { anim.SetBool("isRunning", true); } } private void FixedUpdate() { //Move Speed float h = Input.GetAxis("Horizontal"); rigid.AddForce(Vector2.right * h, ForceMode2D.Impulse); if (rigid.velocity.x > maxSpeed) // Right Max Speed { rigid.velocity = new Vector2(maxSpeed, rigid.velocity.y); } else if (rigid.velocity.x < maxSpeed * (-1)) // Left Max Speed { rigid.velocity = new Vector2(maxSpeed * (-1), rigid.velocity.y); } // Landing Platform if (rigid.velocity.y < 0) { Debug.DrawRay(rigid.position, Vector3.down, new Color(0, 1, 0)); RaycastHit2D rayHit = Physics2D.Raycast(rigid.position, Vector3.down, 1, LayerMask.GetMask("Platform")); if (rayHit.collider != null) { if (rayHit.distance < 1f) { anim.SetBool("isJumping", false); } } } } } | cs |
해당 댓글은 삭제되었습니다.
a, d 혹은 화살표 왼, 오를 누르고 있으면 캐릭터가 좌 혹은 우로 움직이는데 이게 어느 순간부터 멈춰서 캐릭터가 움질이질 않아요 ㅠㅠ
몇 개 건들어보다가 rigidbody2D -> Constraints -> Freeze Rotation -> 'Z' 를 끈 상태에서는 움직임 멈추는 현상이 발견되지는 않았어요 하지만, 캐릭터가 넘어지는 것을 방지하기 위해서는 'Z'를 켜야하는데.. 응애 ㅠㅠㅠㅠ
플랫포머 만드냐 컴포지트 콜라이더 사용하면 블럭 사이에 좆같은 틈 사라짐
그럼 타일맵 2d 지우고 컴포지트 2d 써두 되는건가여? 아님 둘 다 켜야 하나여
둘다써야지 사용법 구글링 해보셈