I am trying to finalize a game for school but I’m having a little scripting issue. I get the turret to react to the player when he gets within a pre-determined distance; however my problem is that the turret seems reversed as it’s the back that follows the player.
Here is the script I am using:
var target : Transform;
var range : float;
var speed : float;
function Update ()
{
range = Vector3.Distance(target.transform.position, transform.position);
if (range<200)
{
transform.rotation = Quaternion.LookRotation(transform.position - target.position);
}
if (range<150)
{
transform.Translate(Vector3.forward*speed*2);
}
}