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: #9 Making a MultiPlayer Game [Unity 3d tutorial] [Adding Bots] - YouTube and the relevant script and application are at 7 minutes in. Any help would be greatly appreciated!

1 Answer

1

Is the head of your turret parented to anything?

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