a simple look away script for you :)

A simple look away script that I thought others might find useful.
There is a bit of weirdness at the poles but it is effective.

Any improvements are appreciated of course.

//Object to look away from.
var A : Transform;
//Object doing the Looking Away.
var B : Transform;
//Amount of lag if using the Smoother Way. Larger numbers are less smooth
//var rotationDamping = 0.5;

function Update ()
{
      //Get far position to look at
      var newPosition = B.position – A.position;

      //Look at far position using LookAt() in effect Looking Away from object A (comment this out if you use the Smoother Way)
      B.LookAt(newPosition);

      //Look at far position in a Smoother Way
      //var lookRotation = Quaternion.LookRotation(newPosition – B.position);
      //B.rotation = Quaternion.Slerp(B.rotation, lookRotation, Time.deltaTime * rotationDamping);
}

For a perfect opposite direction, you’re probably better off doing this:

B.LookAt(B.position + newPosition);