Trying to get turret (or simple cube) to turn toward player

Trying to follow tutorials and online manual to use LookAt to make a turret (or a simple cube for starters) rotate around to face my player / FirstPersonController.

Here's the very simple script I'm using,

var lookAtTarget: Transform;

function Update () 

I've seen some better ways mentioned on other threads, but I'd like to get this very simple one working first before moving on to more advanced methods. I've added this script to my turret's body without luck, and tried with a simple gameObject cube as well. Both times I selected FirstPersonController as my target for the script.

Any suggestions? Not getting any movement/rotation at all as my player walks around the object.


It seems you must have overlooked something very basic.

  1. Create a new scene.
  2. Create a cube.
  3. Create a sphere.
  4. Put the script on the cube and let Look At Target reference the sphere.
  5. Run the game through the editor.
  6. In real time - In scene view, try moving the sphere around. The cube should look at the sphere.

If this works, then your script work. You might have other problems such as:

  1. Your object that should look at the player might have other scripts overriding rotation.
  2. You haven't properly referenced the player transform. Make sure you really referenced the part that moves around, not some root node that is static.
  3. Make sure your script is enabled (however it is enabled by default).
  4. While the game is running in the editor, pause the game and make sure that your reference is set.