- Home /
How to change gravity with a trigger?
I want to change the direction of gravity if you hit a certain object. And the character controller must turn with the gravity so his underside is always facing in the direction of the current gravity.
Answer by fafase · Jul 05, 2012 at 08:39 AM
You may have two ways I see. first you disable the engine gravity and apply your own to the character (if he is the only being involved in the change of gravity).
or you can change the gravity manually:
Physics.gravity.y = -Physics.gravity.y;
In the second case, all rigidbodies will fall down if they have IsKinematic off.
Physics.gravity is a vector3 so you can also modify the values of each three components so that either you get a moon gravity or to the side or else. A little like Gravity Rush.
EDIT: To create gravity with script: it is all there:
http://answers.unity3d.com/questions/36815/gravity-direction-change.html
to create your own gravity, how is it done? Im not so experienced with scripts.
Your answer
Follow this Question
Related Questions
Help,don't know why script not working! 2 Answers
Gravity Direction Change 4 Answers
Can I make gravity work the other way round for one object? 1 Answer
Changing gravity on collision 4 Answers