# How to move rigidbodies

Have i understood this correct: If i want to use a rigidbody for physics then

1. i should not move an object through its transform.position.
2. I should never move it by riigidbody.velocity since i then affect the physics.
3. So what is left is moving it using addForce. I guess its like mimicking how in the real world everything that moves has something that drives it.
• Sounds like you're answering your own question. There's no strict rules. You can do/not do any of the things on your list. There are pros and cons for each. You decide what's worth it and what works for your game. Commented Jan 30, 2014 at 15:52
• This is not a good question for this site. I don't see the problem with rigidbody velocity. Commented Jan 30, 2014 at 15:52

## Why use Rigidbodies?

When you use a rigidbody, then you should use a rigidbody. Allow me to explain what I mean. Often times, when I see developers using rigidbodies; they are neglecting its use. They are:

1. Directly modifying the transforms position and attempting to use the rigidbody correctly
2. Using it for collision response only and doing No.1
3. Have an incorrect understanding of transforms and rigidbodies.

Golden Rule: Use a rigidbody when you want all aspects of your entity to act under the laws of physics (gravity,forces,torque, etc.)

Keeping the golden rule in mind(see above) and the three no-no's, we can talk about how to move your rigid-body. In Unity, you have AddForce() and you have AddTorque().

You might ask the question, "Well, why can't I directly modify the position when using a rigidbody?" in regards to movement, per say.

You can, but you'd essentially be emulating the behavior of a transform, that of which is not able to be acted on by force or torque. Transforms, hence the name, can be "translated", but it's not the same as moving it with physics. Rigid-bodies, however, are able to be acted on by force and torque for movement related purposes. Please note that directly modifying the rigidbody's position is acceptable for certain cases.

Le Documentation

Transform.position on a rigidbody won't do any collision checks and just costs more performance.

Applying force to a rigidbody will move it while checking for collisions and such in a realistic sense. Things like moving up and down a ramp will be faster and slower (because of the direction of force) you could get around this by changing the direction the force is applied to the rigidbody to help sustain a constant movement.

If a rigidbody has a collider on it that is marked as a trigger, no matter how its moved there will be no collisions, but you will be notified when the collider enters another collider. You could make your own collisions this way.

A simple and easy way to do collisions that also takes into consideration angled ramps, is to use a character controller physics component. Don't use one of the preset ones. You just want the component not the default unity prefab. This way you can create your own movement and then call the Move(); method of the character controller component. Unity will then take care of the collisions and ramps. Check the docs for more info on the subject.