Physics - Trying to create rollers.

I’m trying to create some ‘rollers’ that, if a box is placed on them, will roll it.

Currently the rollers are cylinders with rigid bodies set to kinematic (so they are not pushed to the floor by the box) and are rotating from a simple script that calls transform.rotate on each update.

This is working, but very slowly! If I increase the motion it stops and I have tried increasing the weight of the box. Everything has a material of rubber so should be plenty of friction?

I am probably going about it all wrong. Any pointers would be gladly received.

If you want objects to behave physically correct, never set their Transform directly! Instead, apply forces to the Rigidbody (or add torque for rotation) or alternatively set the velocity directly (or angularVelocity for rotations).

See:

Rune

You can always fake it too. OnTriggerStay->AddForce() or rigidbody.MoveDirection(). I like using MoveDirection a lot. It gives really consistent behavior. It’s easy to set-up. It works on kinematics and non-kinematics and it will affect other rigidbodies in a realish way.

Here is a simple conveyor belt script.

var speed = 2.0;
function OnCollisionStay(collision) {
  collision.rigidbody.MovePosition(collision.rigidbody.position + transform.forward * Time.deltaTime * speed);
}

Thanks for the help.

I’ve combined the 2 answers. Faking the applied force with a trigger object.

I created a game object that consists of a number of capsule colliders - the rollers, on top of that a box collider set as a trigger.

In the OnTriggerStay event, rather than use MovePosition I opted for AddForce. As I wanted the object to continue moving after it leaves the conveyor belt.

Hope I can be of help to someone else someday!