이 스크립트의 기능은 wasd와 방향키로 탑다운 뷰에서 움직이고 스페이스 바를 누를 때마다 대쉬를 하는 기능입니다


이동도 잘 되고 대쉬도 되긴 하지만 가끔씩 키가 씹히는 것 처럼 대쉬가 스페이스바를 눌러도 작동 하지 않습니다 어떻게 고쳐야할까요?

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class PlayerController : MonoBehaviour

{

    private Rigidbody2D rb;

    private Vector3 moveDelta;

    public float speed;

    private bool isDashing = false;

    public float dashSpeed;

    public float startDashTime;

    private float dashTime;


    public Animator animator;


    void Start()

    {

        animator = GetComponent<Animator>();

        rb = GetComponent<Rigidbody2D>();

        transform.localScale = new Vector3(0.7f, 0.7f, 1f);

        dashTime = startDashTime;

    }


    void FixedUpdate()

    {

        if (!isDashing)

        {

            // Handle regular movement

            float x = Input.GetAxisRaw("Horizontal");

            float y = Input.GetAxisRaw("Vertical");

            moveDelta = new Vector3(x, y, 0).normalized;


            if (Mathf.Abs(moveDelta.x) > 0 || Mathf.Abs(moveDelta.y) > 0)

            {

                animator.SetBool("running", true);

                transform.localScale = new Vector3(moveDelta.x > 0 ? -0.7f : 0.7f, 0.7f, 1f);

            }

            else

            {

                animator.SetBool("running", false);

            }


            rb.velocity = moveDelta * speed;


            // Check if player is dashing

            if (Input.GetKeyDown(KeyCode.Space))

            {

                isDashing = true;

                if (x != 0 || y != 0)

                {

                    rb.velocity = moveDelta * dashSpeed;

                }

                else

                {

                    rb.velocity = transform.right * dashSpeed;

                }

            }

        }

        else

        {

            // Handle dashing

            if (dashTime <= 0)

            {

                isDashing = false;

                dashTime = startDashTime;

                rb.velocity = Vector2.zero;

            }

            else

            {

                dashTime -= Time.deltaTime;

            }

        }

    }

}