Tip of the Day: Transform.Translate vs Rigidbody

Movement in Unity is usually done through two different methods, either using the Transform of the gameobject or using its rigidbody.

Directly changing the transform of the gameobject in order to move it a certain distance per frame, will ignore the physics system. This way, the gameobject’s velocity will be ignored and will not care for collisions. This method is best suited if physics is not necessary, teleporting for example.

Character completely ignoring physics

Moving an object using its rigidbody allows that object to use the physics system. Allows its velocity to be manipulated or acceleration, and allows for further interaction with other objects. More importantly, it is much more smoother than Transform.Translate. There are three ways to move an object’s rigidbody.

Rigidbody.AddForce

Rigidbody.Addroce() is like pushing an object and giving it a force to move or like pushing the pedal of the car to accelerate. Force is added constantly with time increasing the velocity of the object. If no force is added, the object slows down due to gravity and friction or if it hits an object.

Acceleration based on the added force and deceleration due to gravity and friction

Rigidbody.Velocity

Almost like AddForce, this will add a constant rate over time to the object but without the acceleration and thus overriding all physics elements including gravity. The object is either moving, or it isn’t.

It is either moving or it isn’t.

Rigidbody.movePosition

This resembles Transform.Translate but it allows for physics interactions and it is way more smoother. This will add the object to a specific position based on direction and speed). Just keep in mind that, if the speed is set too high, the object almost ignore collisions.

It moves while allowing for collisions and physics interactions

So which one would you use? That depends on what you actually want from that specific object that you want to move.

A knowledge seeking biologist who is following his passion into a full time career in Unity / Game Development. https://www.linkedin.com/in/mohamed-hijazi/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store