Jump to content

How do I determine if one object is in front of another?


KT Kingsley
 Share

You are about to reply to a thread that has been inactive for 1528 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Given the position and rotation of an object, how do I determine if another object is in front of it?

Also, how would I determine if the other object is within a given angle of the first object's forward axis?

I guess those are both the same question, in that in the first case the angle would be 90°, though I suspect that calculation can be simplified.

Link to comment
Share on other sites

Are you concerned with occlusion? or is this just about the location of the "in front" object's origin?

If the former, you'll need to raycast. The latter is some solid geometry that seems as if it should be pretty simple, but I'm too sleepy to be a reliable source. Off the top of my head, I'm thinking maybe

the llRotBetween

  • the first object's forward axis (llRot2Fwd maybe) and
  • the unit vector in the direction of the possibly-in-front object (maybe llVecNorm of the difference in position vectors).

but like I said, I'm pretty sleepy, so sorry if it's totally wrong or crazily overcomplicated.

  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1528 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...