# Object look at target direction?

How to make an object look at the target direction not at the target himself ?

public Transform target;

void Update() {

transform.LookAt(target);
float step = 2 * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.position, target.position, step);

}

• What do you mean by "target direction"? A specific point in space? The direction that target is looking at (how do you define that?)? Mar 28 '17 at 7:02
• I mean "The direction that target is looking at" Mar 28 '17 at 7:04
• You can't really "look at a direction" - you need to pick a point on the direction vector to look at. (Maybe your question is how to calculate a direction vector and pick a point on it? In that case you should update the question accordingly) Mar 28 '17 at 7:31

If you want one object to look parallel to the sight-direction of another object, you can simply turn it into the same rotation:

this.transform.rotation = target.transform.rotation;


But if you want one object to look at whatever thing another object is looking at, you first need to figure out where that other thing is, because the direction would differ depending on if it's something directly in front of the other object or something at the horizon.

One option is to do a raycast from the other object to find the point where its line of sight is broken and then use LookAt for that point.

RaycastHit hit;
if (Physics.Raycast(target.transform.position, target.transform.rotation.eulerAngles, out hit)) {
this.transform.LookAt(hit.point);
}


Note that Physics.Raycast is only broken by objects with colliders.