2d게임에서 캐릭터가 움직이고 대쉬를 하는 코드를 짰습니다 wasd로 움직이고 스페이스바를 누르면 플레이어가 가는 방향으로 대쉬를 하고 대쉬이펙트를 만드는 코드입니다

그러다가 할로우나이트처럼 처음에는 대쉬가 없다가 후반에 조건을달성해야 얻어야 사용할 수 있으면 더 재밌을것 같아서 코드를 둘로 나누었는데 움직이는건 잘 작동하는데 스페이스바를 눌러도 아무일도 일어나지 않습니다
몇시간동안 해봐도 해결이 안되는데 아직 초보여서 기능을 다 모르는데 혹시 코드에 문제가 있거나 코드를 나누지 않아도 해결할 수 있는 방법이 있을까요

using UnityEngine;


public class PlayerController : MonoBehaviour

{

    private Rigidbody2D rb;

    private Vector3 moveDelta;

    private float xInput;

    private float yInput;

    public float speed;

    private bool isDashing = false;

    public float dashSpeed;

    public float startDashTime;

    private float dashTime;

    private float nextDashTime = 0f;

    public float dashCooldown;

    public Animator animator;

    public GameObject dashEffectPrefab;

    public float dashEffectDuration;


    private void Start()

    {

        animator = GetComponent<Animator>();

        rb = GetComponent<Rigidbody2D>();

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

        dashTime = startDashTime;

    }


    private void Update()

    {

        HandleMovement();

        HandleDashing();

    }


    private void FixedUpdate()

    {

        if (isDashing && dashTime > 0)

        {

            dashTime -= Time.fixedDeltaTime;

        }

        else if (Mathf.Approximately(dashTime, 0))

        {

            isDashing = false;

            dashTime = startDashTime;

            rb.velocity = Vector2.zero;

        }

        else

        {

            rb.velocity = moveDelta * speed;

        }

    }


    private void HandleMovement()

    {

        // Handle regular movement

        xInput = Input.GetAxisRaw("Horizontal");

        yInput = Input.GetAxisRaw("Vertical");

        moveDelta = new Vector3(xInput, yInput, 0).normalized;


        if (Mathf.Abs(xInput) > 0 || Mathf.Abs(yInput) > 0)

        {

            animator.SetBool("running", true);

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

        }

        else

        {

            animator.SetBool("running", false);

        }

    }


    private void HandleDashing()

    {

        if (Input.GetKeyDown(KeyCode.Space) && Time.time > nextDashTime)

        {

            isDashing = true;

            nextDashTime = Time.time + dashCooldown;


            if (Mathf.Abs(xInput) > 0 || Mathf.Abs(yInput) > 0)

            {

                rb.velocity = moveDelta * dashSpeed;


                Vector3 direction = new Vector3(xInput, yInput, 0).normalized;

                float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;

                Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);


                // Instantiate the dash effect prefab

                GameObject dashEffect = Instantiate(dashEffectPrefab, transform.position, rotation);

                Destroy(dashEffect, dashEffectDuration);

            }

            else

            {

                rb.velocity = transform.right * dashSpeed;


                // Instantiate the dash effect prefab

                GameObject dashEffect = Instantiate(dashEffectPrefab, transform.position, transform.rotation);

                Destroy(dashEffect, dashEffectDuration);

            }

        }

    }

}

라는 코드를 이동하는 코드와 대쉬를 담당하는 코드 두개로 나누었습니다

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    private Rigidbody2D rb;
    private Vector3 moveDelta;
    private float xInput;
    private float yInput;
    public float speed;
    public Animator animator;

    private void Start()
    {
        animator = GetComponent<Animator>();
        rb = GetComponent<Rigidbody2D>();
        transform.localScale = new Vector3(0.7f, 0.7f, 1f);
    }

    private void Update()
    {
        HandleMovement();
    }

    private void FixedUpdate()
    {
        rb.velocity = moveDelta * speed;
    }

    private void HandleMovement()
    {
        // Handle regular movement
        xInput = Input.GetAxisRaw("Horizontal");
        yInput = Input.GetAxisRaw("Vertical");
        moveDelta = new Vector3(xInput, yInput, 0).normalized;

        if (Mathf.Abs(xInput) > 0 || Mathf.Abs(yInput) > 0)
        {
            animator.SetBool("running", true);
            transform.localScale = new Vector3(moveDelta.x > 0 ? -0.7f : 0.7f, 0.7f, 1f);
        }
        else
        {
            animator.SetBool("running", false);
        }
    }
}



using UnityEngine;


public class PlayerDashing : MonoBehaviour

{

    private Rigidbody2D rb;

    private Vector3 moveDelta;

    private float xInput;

    private float yInput;

    public float speed;

    private bool isDashing = false;

    public float dashSpeed;

    public float startDashTime;

    private float dashTime;

    private float nextDashTime = 0f;

    public float dashCooldown;

    public Animator animator;

    public GameObject dashEffectPrefab;

    public float dashEffectDuration;


    private void Start()

    {

        animator = GetComponent<Animator>();

        rb = GetComponent<Rigidbody2D>();

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

        dashTime = startDashTime;

    }


    private void Update()

    {

        HandleDashing();

    }


    private void FixedUpdate()

    {

        if (isDashing && dashTime > 0)

        {

            dashTime -= Time.fixedDeltaTime;

        }

        else if (Mathf.Approximately(dashTime, 0))

        {

            isDashing = false;

            dashTime = startDashTime;

            rb.velocity = Vector2.zero;

        }

        else

        {

            rb.velocity = moveDelta * speed;

        }

    }


    private void HandleDashing()

    {

        if (Input.GetKeyDown(KeyCode.Space) && Time.time > nextDashTime)

        {

            isDashing = true;

            nextDashTime = Time.time + dashCooldown;


            if (Mathf.Abs(xInput) > 0 || Mathf.Abs(yInput) > 0)

            {

                rb.velocity = moveDelta * dashSpeed;


                Vector3 direction = new Vector3(xInput, yInput, 0).normalized;

                float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;

                Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);


                // Instantiate the dash effect prefab

                GameObject dashEffect = Instantiate(dashEffectPrefab, transform.position, rotation);

                Destroy(dashEffect, dashEffectDuration);

            }

            else

            {

                rb.velocity = transform.right * dashSpeed;


                // Instantiate the dash effect prefab

                GameObject dashEffect = Instantiate(dashEffectPrefab, transform.position, transform.rotation);

                Destroy(dashEffect, dashEffectDuration);

            }

        }

    }

}