I’m using this code to make my character dash
rb.AddForce(moveInput.normalized * 60000);
It works but looks more like a teleport. How would I go about smoothing this down so it looks more like a smooth sliding motion?
If you’re looking for a consistent dodge that happens over time, there’s a couple ways to do it. You could use a coroutine or you could use Update and a “dodge flag”. For example, a coroutine could look like this:
/// Dodge distance/speed that gets processed every frame. Might wanna keep this low!
private float _dodgeSpeed = 60000;
/// How long dodges last.
private float _dodgeTime = 0.5f;
/// Reference to the dodging coroutine.
private Coroutine _dodging;
private void Update()
if (Input.GetKeyDown(KeyCode.LeftControl) && _dodging == null)
_dodging = StartCoroutine(DodgeCoroutine());
private IEnumerator DodgeCoroutine()
var endOfFrame = new WaitForEndOfFrame();
var rigidbody = GetComponent<Rigidbody>();
for (float timer = 0; timer < _dodgeTime; timer += Time.deltaTime)
rigidbody.MovePosition(transform.position + (transform.forward * (_dodgeSpeed * Time.deltaTime)));
yield return endOfFrame;
_dodging = null;
For an Update() implementation you would do the same thing but replace the _dodging Coroutine with a _dodging boolean. Then,
if (_dodging) aforementionedLogic();