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?

  • 1
    \$\begingroup\$ Have you tried to set the objects' materials? My answer isn't ok? \$\endgroup\$ – fableal Oct 17 '12 at 14:59

I tried to replicate your example and you're right:

I had to set the plane's material to Ice to see the cube moving as it should. Without a material set to the plane, the cube won't "slide" forward (will do a simple somersault) for values like 25, and for bigger values (like 250) the cube's behaviour is really weird!!! (it moves forward, that moves backwards, then starts flying in the upper direction!!! Really funny; here is a link to a video).

To have access to the Ice material you have to import the Physic Materials package.

To set the plane's material you have to select the plane and go to Mesh Collider -> Material.

| improve this answer | |
  • \$\begingroup\$ +1: yes, actually using ice (dynamic and static friction low, friction/bouncing combine minimum) reduce this problem. I still don't understand the reason. \$\endgroup\$ – Heisenbug Oct 22 '12 at 12:55
  • \$\begingroup\$ Might be due to the physics engine (friction, ...), if you try lowering the cube's mass, you don't have to set materials at all. \$\endgroup\$ – fableal Oct 22 '12 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.