x


transform.LookAt causes my object to explode

I am following a simple tutorial to learn Unity- in the tutorial, I am attempting to make a turret who's head always rotates to follow the player's location. The script is the one from the Unity Script Reference:

var target : Transform;

function Update() { transform.LookAt(target); }

This script is used in the tutorial, and works great for them. But, when I use it (or the SmoothLookAt script that comes with Unity), applying it to the part I want to rotate (the turret head) and targeting my character (the worm), the turret head flies off to a seemingly random location and orbits around my character as I move it. Any ideas?

For reference, the tutorial I am following can be found here: http://www.youtube.com/watch?v=u8t3fdKhDxg&feature=relmfu and the relevant script and application are at 7 minutes in. Any help would be greatly appreciated!

more ▼

asked Oct 13 '11 at 10:27 PM

Tommas gravatar image

Tommas
1 3 3 3

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

1 answer: sort voted first

Is the head of your turret parented to anything?

more ▼

answered Oct 13 '11 at 10:49 PM

Jason B gravatar image

Jason B
1.7k 29 32 44

Yeah, make sure your turret head is parented to the body.

Oct 13 '11 at 11:19 PM Overlord

That did it! Thanks! I will understand this, eventually. :)

Oct 13 '11 at 11:42 PM Tommas
(comments are locked)
10|3000 characters needed characters left
Your answer
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:

x3890
x747
x337
x326
x173

asked: Oct 13 '11 at 10:27 PM

Seen: 1095 times

Last Updated: Oct 14 '11 at 01:14 AM