이거 움짤 올리는 방법 모르겟음;; 클릭해야 움직임


더블 점프 만들었는데 캐릭터 이동 코딩에 문제가 있어서 그런지

두 번째 점프를 좀 늦게 하면 점프가 짧게 되고 

첫 번째 점프 하고나서 바로 두 번째 점프 누르면 점프가 존나게 길어짐


캐릭터 이동은 targetVelocity 만들어놓은다음 smoothDamp로 이동하는거고

점프는 리지드바디 AddForce 썻음


이거 혹시 해결하는 방법 아시는분 점프되는 높이가 좀 일정했으면 좋겟는데


+ 아 글고 기본 상태랑 뛰어다니는 애니메이션은 잘 나오는데 점프 애니메이션이 이상함

애니메이터에 jump 변수 만들어놓고 점프 할때마다 jump변수가 true되도록 했는데 

점프하자마자 0.1초정도 jump = true됐다가 false되고 바로 달리기 애니메이션으로 넘어가버림


++코드

[SerializeField] private float speed;

    [SerializeField] private float jumpForce;

    [Range(0, .3f)] [SerializeField] private float m_MovementSmoothing = .05f;

    [SerializeField] private Transform groundCheck;    

    [SerializeField] private LayerMask whatIsGround;

    [SerializeField] private Animator animator;


    const float checkRadius = 0.2f;

    private float moveInput;

    private Rigidbody2D rb;

    private bool facingRight = true;

    private bool isGrounded;

    private int extraJumps = 1;

    private Vector3 refVelocity = Vector3.zero;


    void Start () {

        rb = GetComponent<Rigidbody2D>();

}


void FixedUpdate () {

        bool wasGrounded = isGrounded;

        isGrounded = false;


        Collider2D[] colliders = Physics2D.OverlapCircleAll(groundCheck.position, checkRadius, whatIsGround);

        for (int i = 0; i < colliders.Length; i++)

        {

            if (colliders[i].gameObject != gameObject)

            {

                isGrounded = true;

                if (!wasGrounded)

                    animator.SetBool("Jump", false);

            }

        }


        moveInput = Input.GetAxisRaw("Horizontal");

        Vector3 targetVelocity = new Vector3(moveInput * speed * Time.fixedDeltaTime, rb.velocity.y);

        rb.velocity = Vector3.SmoothDamp(rb.velocity, targetVelocity, ref refVelocity, m_MovementSmoothing);

        animator.SetFloat("Speed", Mathf.Abs(moveInput) * speed);

        if (facingRight == false && moveInput > 0) {

            Flip();

        }

        else if (facingRight == true && moveInput < 0) {

            Flip();

        }

        

}


void Update()

    {

        if (isGrounded == true)

        {

            extraJumps = 1;

        }

        if (Input.GetButtonDown("Jump") && extraJumps > 0)

        {

            isGrounded = false;

            animator.SetBool("Jump", true);

            rb.AddForce(new Vector2(0.0f, jumpForce));

            extraJumps--;

        }

        else if (Input.GetButtonDown("Jump") && extraJumps == 0 && isGrounded == true)

        {

            isGrounded = false;

            animator.SetBool("Jump", true);

            rb.AddForce(new Vector2(0.0f, jumpForce));

        }

    }