- Home /
Why does gravity's vector3 act so weird?
So I was wanting to play around with gravity and change the direction using the vector 3 so I did this:
function Start () {
Physics.gravity = new Vector3(1f,0f,1f);
}
And applied it to a cube, stretched out to a plain. Then I put a sphere on the plain with a ridged body.
When I hit play I noticed two immediate issues. 1) The sphere didn't rotate. It just slid along the plain. 2) The sphere continued its course in heading down x and z plains, but didn't drop when it went off the edge of the plain.
I then tried the same by removing the code and then just tilting the plain and camera and got the results I expected.
What's going on here? Is the gravity's Vector3 not really changing gravity's direction?
Thanks!
Answer by Bunny83 · May 31, 2014 at 11:42 PM
Grafity don't really act weird and changing Physics.gravity will change the direction and value of gravity. The only thing that looks weird where is your gravity vector. You changed it from the default {
Vector3(0f, -9.81f, 0f);
to
Vector3(1f, 0f, 1f);
which looks a bit weird ;)
First of all you changed the value from 9.81 to 1.414. Second your gravity vector now points 45° forward-right.
I'm not sure what you want to do here and what's the "results you are expecting", your vector just looks strange.
How is your plane oriented?
Oh, man. I feel stupid.
This makes sense.
Thank you.
EDIT: Hmm... Now I just need to write a code to change the only x on a key down and only the z on another.