Need help on LookAt scripting problems.

Hey guys, I've been working on my games for a while now and I have something that get me stuck for the longest time...

I am currently using a script to let an Arrow pointing to the location "Mailbox" (with tag "Mail") in my game.

The objective is, when you need to deliver your mail to the mailbox, the arrow will look for the closest mailbox with tag "Mail" and point to that location.

I use the following script:

function Update () { var waypoints: GameObject[] = GameObject.FindGameObjectsWithTag("Mail"); var closest: GameObject; var closestDist = Mathf.Infinity;

for (waypoint in waypoints) { var dist = (transform.position - waypoint.transform.position).sqrMagnitude;

if (dist < closestDist) { closestDist = dist; closest = waypoint; }

} transform.LookAt(closest.transform);


The script works pretty well, but what I really want to do is, after all mail has be delivered (will all tag "mail" object has been destroy). I want the arrow point to the finishing location, which is a Truck (tag with "truck"). I am having hard time to do that and I am not good at scripting, I try a lot of method but it didn't work at all...

I hope you guys can give me some idea and I will learn from there, thank you very much!

Do you mean something like this:

var lookAtTarget : Transform; //Drag the target here.

function update ()

Which looks at the target everyframe.