While fiddling with the player handing for Chalo Chalo, it became important for me to get a better grasp on the difference s between the four modes in Unity3d.
If you have objects this use Unity's physics system, via a rigidbody component, you can add forces to them to get them to Move. Forces can added using one of four different ' modes '. The names of these modes aren ' t very enlightening and I don ' t think the Unity3d documentation is very clear about their di Fferences. For my own reference, and in the case it helps others, the This was what I've figured out.
- Forcemode.force. If The Addforce call occurs with a fixedupdate loop, the full force supplied to the Addforce call 'll only has been exerted on the rigidbody after one second. Think of it as ' force exerted per second '
- forcemode.acceleration. Like Forcemode.force, except the object's mass is ignored. The resulting movement would be as though, the object has a mass of 1. The following lines would give the same result
Rigidbody. Addforce ((Vector3.forward *), forcemode.force); Rigidbody. Addforce ((Vector3.forward *)/rigidbody.mass,forcemode.acceleration);
- Forcemode.impulse. The entirety of the force vector supplied to the addforce call would be applied all at once, IM mediately.
- forcemode.velocitychange. Like Forcemode.impulse except the object's mass is ignored. So the following lines give the same result:
Rigidbody. Addforce ((Vector3.forward *), forcemode.impulse); Rigidbody. Addforce ((Vector3.forward *)/rigidbody.mass,forcemode.velocitychange);
I made a little test to verify. The script demonstrates how the forcemodes is canceling out their differences through modifying the values passed to The Addforce call.
Here's the C # script that is attached to each of the cubes. In the inspector, the Forcemode property of each is set to use one of the four modes.
Using unityengine;using System.collections;public class Force_force:monobehaviour {public Forcemode forceMode;void Fixedupdate () {Addforce ();} void Addforce () {float massmodifier=1f;float timemodifier=1f;//Modify things to make all give same result as forcemode.for Ceif (Forcemode==forcemode.velocitychange | | forcemode==forcemode.acceleration) {massmodifier=rigidbody.mass;} if (Forcemode==forcemode.impulse | | forcemode==forcemode.velocitychange) {timemodifier=time.fixeddeltatime;} Rigidbody. Addforce (((Vector3.forward *) * timemodifier)/massmodifier,forcemode);}}
Original
Understanding Unity3d's Forcemode | Understanding Forcemode in Unity3d