0
\$\begingroup\$

I've got a Unity project with an imported .fbx model I'm attempting to add movement to.

As a test, I've added a sphere primitive with a sphere collider, a rigid body, and the following script:

public class ball_test : MonoBehaviour {

  private Rigidbody rb;

  void Start ()
    {
    rb = GetComponent<Rigidbody> ();
    }

  void FixedUpdate ()
    {
    Vector3 movement = new Vector3 (1f, 0.0f, 1f);

    rb.AddForce (movement);
    }
  }

This is partly copied from the Roll A Ball tutorial, and this works fine. The ball slowly rolls with no problem.

I've imported a custom model, added a box collider, a rigid body, and assigned to it the same script. It doesn't move.

Here's how they're set up:

Sphere Car

\$\endgroup\$
  • 1
    \$\begingroup\$ This seems like a problem with friction. Try to make a Physic material with Zero friction and set it in the Collider component. \$\endgroup\$ – Aditya Yadav Nov 24 '17 at 5:50
  • \$\begingroup\$ @AdityaYadav, No change. \$\endgroup\$ – Nightmare Games Nov 24 '17 at 5:58
  • 1
    \$\begingroup\$ Have you tried just cranking up the force? It's harder to slide a crate than roll a wheel. ;) \$\endgroup\$ – DMGregory Nov 24 '17 at 6:06
  • \$\begingroup\$ @DMGregory, yep, that was it. \$\endgroup\$ – Nightmare Games Nov 24 '17 at 6:12
  • \$\begingroup\$ Cool. Maybe share the force values you needed to use as an answer so future users can get a sense of how much they need to crank it up in similar situations. \$\endgroup\$ – DMGregory Nov 24 '17 at 6:12
0
\$\begingroup\$

The difference here had to do with the sphere collider versus the box collider. I didn't realize the physics engine was taking the shape of the object into consideration.

The box requires a lot more force to move than the sphere.

I had to increase the force on the custom model to at least 6f before I saw any movement, where as 1f was fine for the ball.

There was also too much friction with the ground.

I had to apply a zero friction physic material to the model's box collider. Without this, the car would move at 10f, but just roll over end-to-end instead of sliding/driving.

\$\endgroup\$

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.