Unity Movement Translate VS RigidBody


Moving with translate is easy. All you need is to grab the transform (object) and apply a translate which includes a vector 2 for direction, then speed and time.


There are three method of moving with RigidBody, use the function AddForce(), set the velocity, or the function MovePosition(). The setup is simple, add a RigidBody, create a variable for speed, and make a Vector2 for movement.


The function AddForce() is simple, give it a direction and a speed variable and it’ll apply a force towards the direction at a constant rate. The longer the button is hold down, the more force the object will receive. The object will then slow down depending on the gravity and friction.


Setting the velocity is similar to adding force, all you need is direction and speed. However setting velocity this way will override all physic elements including gravity, and there will be no acceleration.


The function MovePosition() requires you getting the current position of the object, then add the new direction with the speed and time into it. Since I have been using Vector2 for movement, and the current position of the object is a Vector3, I’ll need to forcefully change the variable to a Vector2 instead. This step is unneeded if you are using a Vector3 for movement.



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