- Home /
Explain why the y-axis of the GameObject's position is not exactly zero when rigidbody is added to it.
I've created a game object and added a rigidbody to it. In the scene editor/viewer I set its position to 0, 10, 0. And it is scaled to 1, 2, 1. Next, I changed the position of another game object (the floor) to 0, -.05, 0.
After I clicked on the play button, the game object falls down (due to the gravity). After it hits the floor, it does nothing else, which is normal.
I then noticed that the y-axis of its position is not exactly 0 but rather 0.48 and it doesn't change unless I change the y-axis of the floor's position. Can you please explain why? How can we fix it?
$$anonymous$$aybe there is a little bounce or something like this. Try to apply a Physics$$anonymous$$aterial to your collider with 0 bounce ect. If the GameObject should do nothing more than fall to the ground you yould also freeze the y and x position under the RigidBody settings
$$anonymous$$ake sure your object is just above the floor. If it is crossing floor it will fall down.
The object is above the floor and is not moving, which is normal. I am just wondering, why the y-axis is not exactly 0? Also, giving it a material with 0 bounce does not change.
Answer by Owen-Reynolds · May 24, 2014 at 08:30 PM
Two things:
1) How thick is the floor's collider? What is the collider y-centering? What kind of collider does the player have? Some are taller than others, or scale funny (spheres, if not all scales the same.) Finding the exact top of the floor collider, or exact bottom of yours, often requires some math.
2) The physics system allows (and, I think, requires) objects to interpenetrate a little bit. Stack some 1x1x1 rigidbody cubes on top of each other, and you'll see the same effect (each will be only about 0.99 higher.) This might be accounting for the 0.02 (0.5-0.48) change.
The setting (I think) is in Edit->Physics->MinPenetation. But feel like setting it to 0 just makes nearly resting objects shake too much.
The amount is consistent. You can usually not worry about it, but accounting for it in code seems to work.
Your answer
Follow this Question
Related Questions
How to determine the direction of an object to the player. 1 Answer
How can I increase or decrease a position based on another variable ? 1 Answer
How to rotate the axis of a 3D GameObject 1 Answer
Take final position after a force applied to a GameObject 1 Answer
Need insight on strange (simple) 2D object transform bug 0 Answers