LookAt problems

Hi all,

I’m a huge Unity newbie, trying to learn from the worm-project (Tornado twins @ youtube). I have some problems with the “LookAt” method - it seems to move my turret around some axes (Strange behavior)? The turret should be looking at the worm-object.

I really want to learn, so please help a newbie out :).

  • Qzy

Edit: Here’s a direct link to the webplayer (might be easier to show my problem!)

http://www.jonnielsen.net/WebPlayer.html

Again, any help would be very much appreciated. :).

Updated with direct link to webplayer :slight_smile: easier! The “turret head” that is moving around should be on the cube, aiming towards the worm - in stead it’s moving around randomly.

What is the intended Behavior may i ask? Because from the web build, it seems that the “turret” just randomly go around whenever i get near it.
Is it supposed to just sit there and rotate towards the main player (worm) instead?

Exactly! I can post the script I have attached to the body/barrel of the turret (not the cube it stands on):

var LookAtTarget:Transform;
function Update () {
transform.LookAt(LookAtTarget);
}

I solved it :slight_smile: Seemed to be a position problem! Turret were not at 0,0,0 inside the game object, making it spin around an invisible point.

Okay okay. Icic. Glad it is working for you now.