Eye look direction

Hi

I am working on a little game where a character’s glass eye needs to look at wherever the player touches the screen. For some reason my code works in reverse. The eye looks away from where the player touches the screen. I know it must be really simple, like putting a minus somewhere, but I can’t figure out where.

function Update () { 
      for (var touch : iPhoneTouch in iPhoneInput.touches) { 
            var ray = Camera.main.ScreenPointToRay(touch.position);                   
            var hit : RaycastHit; 
            Physics.Raycast (ray, hit);           
            transform.rotation = Quaternion.LookRotation(transform.position - hit.point); 
      }
   }

A to B is B - A, so your last line should read:

transform.rotation = Quaternion.LookRotation(hit.point - transform.position);

Hi Bren

For some reason that doesn’t work at all. I can only see the white of the eye, presumably because the iris and pupil are on the opposite side.