Calculating a position in line of sight (extrapolation of raycast/ vector?)

Hey everyone,

I’ve been playing with this for some time now, but I can’t find a solution for this. Basically what I want to know is the Vector3 of a position behind an object (from a player’s point of view). This position would always be a constant distance from the object, but also be always updated to be behind it. In top-down view (where P = player, O = object, V = desired Vector3):

P ------- O --- V

and from a different angle:

     V
    /
   O
  /
 /
P

What would be the best way to go about it? I’ve been thinking about extrapolating a raycast, as well as using a normalized (O.position - P.position), but I can’t seem to get the effect I’m going for.

As always, any help would be much appreciated!
-Patrick

That code is obviously wrong.

Ahah! so funny!

This is what you want. Assuming O and P are not coincident or nearly coincident, you can compute V as:

O + normalize(O - P) * desired_distance

Megmaltese: LOL, thanks for pointing that out… xD;

Jesse: D’ow! It makes perfect sense now that you wrote it down - I just forgot to add the original O.position to the normalized vector. Thanks so much! =)