- Home /
Difference between translate and velocity
I am making a 3d game where i need to move the Rocket in the forward direction but i am confused between transform.Translate and rigidbody.velocity.which one should i use or in other words what is the difference between these two?
Answer by Owen-Reynolds · May 13, 2014 at 02:00 PM
Lots of guys like to make games with rockets, so plenty hear to read about it,
As Noob_Vul notes, setting velocity (which requires a rigid body) tells the physics engine to move it. Transform.translate moves it directly, right in your code. In both cases, the direction are the same. If the rocket's blue arrow is the tip, the transform.forward
is the way it should move.
Velocity can be set once when you fire it, and then left alone. The speed is in meters/second, so transform.forward*12
is reasonable. If gravity is checked, the rocket will naturally make an arc (but it won't angle the tip down -- neither method will.)
Transform.translate needs to be called every frame (maybe in the rocket's Update) and is in meters this frame. So, to move at 12 meters/sec, would use transform.position+=transform.forward*12*Time.deltaTime;
. That last thing (T.dt) is usually about 1/60th.
The real difference, which isn't important for an exploding rocket, is that trans.trans is like dragging it in the Inspector. It will move right through everything. Using a rigid body with velocity will let it bounce and spin off of other objects.
Answer by Noob_Vulcan · May 13, 2014 at 12:01 PM
Rigidbody makes use of Physics Engine .So making too many objects rigidbody is expensive (well , just try to minimize it ). e.g you can workout without using rigidbody on Bullets,rockets etc.
In your case transform.Translate is good since you u only have to move it in forward direction. If your rocket is homing missile then you can use transform.LookAt(your_enemy)