Quantcast
Channel: Answers for "Constant force"
Viewing all articles
Browse latest Browse all 4

Answer by SilverTabby

$
0
0
There are two ways to change the gravity affecting an object: You can change the Physics.gravity constant to affect all objects or you can add gravity by hand Editing [Physics.gravity][1] is simple (see the doc link) but affects EVERYTHING To apply a diffrent gravity to this object, have a script that does the following: - [rigidbody.useGravity][2] = false; - Holds a var localGrav : Vector3 = Vector3.up * -9.8;//down 9.8 m/(s*s) is earth's gravity - Inside of LateUpdate, - [rigidbody.AddForce][3]( localGrav, [ForceMode][4].Acceleration ); Now just change localGrav and your rigidbody will move at a localized, custom gravity amount [1]: http://unity3d.com/support/documentation/ScriptReference/Physics-gravity.html [2]: http://unity3d.com/support/documentation/ScriptReference/Rigidbody-useGravity.html?from=Physics [3]: http://unity3d.com/support/documentation/ScriptReference/Rigidbody.AddForce.html [4]: http://unity3d.com/support/documentation/ScriptReference/ForceMode.html

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>