Question by
Mehatemyself · Oct 19, 2020 at 09:34 AM ·
movement script
Why doesnt this code dash I dont see any issues with it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThirdPersonDash : MonoBehaviour
{
Movement moveScript;
public float dashSpeed;
public float dashTime;
// Start is called before the first frame update
void Start()
{
moveScript = GetComponent<Movement>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.LeftShift))
{
StartCoroutine(Dash());
}
}
IEnumerator Dash()
{
float startTime = Time.time;
while (Time.time < startTime + dashTime)
{
moveScript.controller.Move(moveScript.moveDir * dashSpeed * Time.deltaTime);
yield return null;
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613014047im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can anyone help me with a simple JS wait problem 0 Answers
camera moving in mouse direction 0 Answers
3D space movement: character stuck at edge in free space 0 Answers
How do I make an object move in the direction its facing? 1 Answer
Why does my character keep moving after I release the input? 1 Answer