'How to make a dash in c#? (Unity 2D)
So, I am a really inexperienced scripter, so I would be so glad if you could help me. My friend made the movement system and he asked me to implement a dash, that's what he said to me: "I was thinking of just like grabbing a vector at a fixed distance and DOTWEENing to it". This is what I tried to do, unfortunately it doesn't work.
////GET THE INPUT AS A VECTOR/////
Vector2 move = playerInput.Player.Movement.ReadValue<Vector2>();
////MOVE THE PLAYER/////
playerRigidbody2D.MovePosition(transform.position + speed * Time.fixedDeltaTime * (Vector3)move);
/////add a dash key here
/////if dash and direction pressed
if (Input.GetKeyDown(KeyCode.Space) && move != null)
{
playerRigidbody2D.MovePosition(transform.position += (Vector3)move * dashDistance);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
