Hi. Im trying to make guided missile. But I cant make it chase other objects… It should fly straight to the target ( if collision occurs then it explodes, no matter if was it target or wall on target’s path ). Could anyone help me ?
Get the direction (in quaternion) you need to “look at” and lerp your rotation and the target rotation.
and simply go straight according to your rotation, using transform.forward
to get the target rotation use Quaternion.LookRotation() function
To get that direction, you take target - position and normalize it.
var dir2target:Vector3 = (target.transform.position - transform.position).normalized;
// smoothdamp, slep, or just apply it instantly
transform.rotation = Quaternion.LookRotation(dir2target);