- Home /
Question by
jpn-t_21 · Sep 11, 2020 at 04:24 AM ·
c#3dcharacter controllerdash
I need help with a dash move script
I have this dash script and I have tried that when I am on the ground I have an infinite amount of dash, but when I am in the air I can only do it once. Could you help me.
CharacterController Player;
public Vector3 Direction;
public const float maxDashTime = 1.0f;
public float dashDistance = 10;
public float dashStoppingSpeed = 0.1f;
float currentDashTime = maxDashTime;
public float dashSpeed = 6;
public float timeToDash;
float delayTime;
private void Awake()
{
Player = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
if (Player.isGrounded)
{
if (Input.GetButtonDown("Fire3"))
{
currentDashTime = 0;
}
if (currentDashTime < maxDashTime)
{
Direction = transform.forward * dashDistance;
currentDashTime += dashStoppingSpeed;
}
else
{
Direction = Vector3.zero;
}
Player.Move(Direction * Time.deltaTime * dashSpeed);
}
else
{
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to change the player's forward direction and make turning more smooth 0 Answers
Rotating the game object with direction of mouse move 0 Answers
Character controller for C#? 1 Answer