- Home /
Question by
Rhys_Pieces · Apr 04, 2012 at 07:01 PM ·
aiturret
Trouble with turret script
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);
}
}
Comment
Best Answer
Answer by Owen-Reynolds · Apr 04, 2012 at 09:57 PM
http://answers.unity3d.com/questions/234178/enemy-not-facing-target-direction-waypoint-correct.html
Your model is probably facing backwards.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
trouble with my lookAt script 0 Answers
turret AI question 3 Answers
Scripting error comes up when I press play 1 Answer
Turret Movement 1 Answer