- Home /
reversing gravity for particular GameObjects
hi guys, i have some gameobjects that i want to fall upwards when they enter inside a trigger using this. var gravity : float = -9.81; function OnTriggerStay (other : Collider) { //other.attachedRigidbody.isKinematic = true; //Physics.gravity = Vector3(0, -9.81, 0); //gravity = - gravity;
Physics.gravity.y = -Physics.gravity.y;
} but when my selected gameobjects enter the trigger, every other rigidbody gameobject in my scene fall upwards. please how do i apply this for the gameobects in the trigger only,like this, for isKinematics. //other.attachedRigidbody.isKinematic = true; where other refers to objects in trigger alone. thanks
Answer by fafase · Oct 13, 2013 at 10:15 AM
use
rigidbody.useGravity = false;
Then apply a y velocity so that your guys goes upward. When leaving the box, remove the velocity and reset the gravity.
Your answer
Follow this Question
Related Questions
Walking on walls JS 2 Answers
Manipulate gravity in an area? 1 Answer
My Planet Gravity system not working? C# 1 Answer
time dilation & gravity Effect Not working propperly 1 Answer
Flip gravity 0 Answers