How to site the FPC down a line connecting 2 objects

I am trying to figure out how to compute the “line of site” between two objects such that I get a position and a rotation in x, y and z that I can then apply to the first person controller so that it “sites” down the line between the two objects. Obviously, the position can be anywhere along the “line of site”, but I’m assuming there can only be one correct rotation. My goal is to then have user press an arrow key and watch the FPC travel exactly between the two objects. Any help will be appreciated. Thanks.


Given the transform of two objects named obj1 and obj2, you can do:

var dir : Vector3 = obj2.position - obj1.position;
var midPoint : Vector3 = obj1 + dir / 2.0;
var rot : Quaternion = Quaternion.LookRotation(dir);

‘midPoint’ is the position half way between obj1 and obj2. ‘rot’ is the rotation that looks at obj2 from the midpoint.