Strange behavior of RigidBody with gravity and impulse applied
Posted
by
Heisenbug
on Game Development
See other posts from Game Development
or by Heisenbug
Published on 2012-09-13T16:31:34Z
Indexed on
2012/09/13
21:50 UTC
Read the original article
Hit count: 286
I'm doing some experiments trying to figure out how physics works in Unity.
I created a cube mesh with a BoxCollider
and a RigidBody
. The cuve is laying on a mesh plane with a BoxCollider
.
I'm trying to update the object position applying a force on its RigidBody
.
Inside script FixedUpdate
function I'm doing the following:
public void FixedUpdate()
{
if (leftButtonPressed())
this.rigidbody.AddForce( this.transform.forward * this.forceStrength, ForceMode.Impulse);
}
Despite the object is aligned with the world axis and the force is applied along Z axis, it performs a quite big rotation movement around its y axis. Since I didn't modify the center of mass and the BoxCollider position and dimension, all values should be fine.
Removing gravity and letting the object flying without touching the plane, the problem doesn't show. So I suppose it's related to the friction between objects, but I can't understand exactly which is the problem.
Why this? What's my mistake? How can I fix this, or what's the right way to do such a moving an object on a plane through a force impulse?
© Game Development or respective owner