x


trouble with my lookAt script

I am trying to clean up some issues im having in my game.

I use this script on my turret body it recognizes when the player gets in range, however the turret is reversed when i moves and looks at the player. So its the back of the turret that actually follows the player. How do i fix this?

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); } }

more ▼

asked Apr 04 '12 at 07:01 PM

Rhys_Pieces gravatar image

Rhys_Pieces
5 3 5 6

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5088
x960
x172

asked: Apr 04 '12 at 07:01 PM

Seen: 399 times

Last Updated: Apr 04 '12 at 07:01 PM