Gravity value changes, has no effect.

I have a simple scene. A box that acts as a button with a simple onMouseUp function on a javascript attached.
I have another box, rigidbody with no scripts.
When the scene starts the rigidbody drops and I want the ‘button’ to reset Unity’s physics to something else (to pull object in another direction) like so;

function Start () {
	Physics.gravity = Vector3(0,0,0);

function Update () {

function OnMouseUp()

	Physics.gravity = Vector3(0,0,-100);

With this setup nothing happens. A debug.log tells me the gravity does indeed change though.
When I remove the start function however, the box drops (as it now has default Unity gravity) and when I click the button gravity changes and it gets pulled away.

I’m guessing that the starting gravity value doesn’t like to be changed.
If I manually change the gravity in the inspector to 0,0,0 then I have the same issue, no new gravity value affects the rigidbody at all IF the starting value is 0,0,0.

Any clues as to what’s going on?
Thank you!

EDIT I should point out that the desired effect here is to have an object suspended in space until a gravity force is applied to the world.

Solved it - Partly my fault for not knowing that the rigidbodies fail to wake up if gravity changes and they are already at rest.

To summarise for anyone else who confuddles themselves like me - If you set the starting gravity to 0,0,0 to suspend your objects, they are asleep as soon as the game starts.
If you change the gravity they will not respond because they are asleep!

So, I looked up how to force them to wake up and wrote a script that would check if the gravity value changes and then wake them up every time it does. Works as I had hoped :slight_smile:

What i read in your question seems to be quite simple…

You set the gravity to zero at start… all directions.

Later on, you set it to Vector3(0,0,-100) on a MouseUp event.
Well my friend, as you said that the object(box here) gets pulled away seems to be correct.
as you set the gravity in the negative z-axis’ direction…

One more thing, as you said it is getting pulled away, i think, your camera must be looking in negative z-axis direction, so it is getting pulled away for you.
Hope this helps… and if it does. mark the question as solved.