About Forces and Time.deltaTime


I’m a bit confused. Is there a need to use Time.deltaTime to calculate forces on Objects?
Or is it only required if I calculate the position directly?

using UnityEngine;
using System.Collections;

public class test : MonoBehaviour {

	void FixedUpdate () {
		if(Time.time < 10)
			rigidbody.AddForce(Vector3.forward); // * Time.deltaTime ? 

			Debug.Log("Speed: " + rigidbody.velocity.magnitude + " Time: " + Time.time);

To clarify.

With AddForce you don’t need Time.deltaTime because the physics engine will compute everything for you.

BUT if you do stuff like transform.Translate(amount).
amount MUST depend on Time.deltaTime. So tranform.Translate(amount * Time.deltaTime)

It is important because even if your fixedDeltaTime is quite constant during the game. You may change it for performance reaons. So if you don’t use Time.deltaTime, you will have to change all your values!

Also, never use Time.fixedDeltaTime. It is a good practice to always use Time.deltaTime (either on Update or FixedUpdate).

Detailed answer here: why using DeltaTime with AddForce ? - Unity Answers

TL;DR You do NOT need to multiply by deltaTime to get timestep independent physics.


FixedUpdate() gets called at fixed time intervals (as determined by your project’s physics timestep). So, calling AddForce() in FixedUpdate, as you are currently, will apply a force at a given rate over several frames. If you were to multiply that force by Time.deltaTime - the time it took to render the last frame - you’d just be adding an unnecessary, arbitrary, varying scale factor.

Time.deltaTime is used in Update() - which, unlike FixedUpdate, can be called a varying number of times each second - in order to change variables at a rate that is independent of the number of times the function is called.