Jump to content
  • Advertisement
Sign in to follow this  

target line

This topic is 4878 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to simulate a target locator line to show which way my aircraft needs to fly in order to find the ground target. Right now, I have no problems if the target is straight ahead and I am not banking right nor left. The problem arises when my target is aft of my aircraft and I am banking right or left. Instead of directing me to fly to the right (I am banking right), it directs me to dive down (I will crash to the ground if I follow the line). Hope that the illustration below helps to see the problem clearer. wrong display for banking right: + | correct display for banking right: +-- The "+" sign is the origin where the target locator vector starts.

Share this post

Link to post
Share on other sites
Can you just restrict the test to the ground plane, and have your target locator respond to that? Let's say the ground plane is xy. Then:

Vector2 planePos(plane.pos.x, plane.pos.y);
Vector2 planeDir(plane.dir.x, plane.dir.y);
Vector2 targetPos(target.pos.x, target.pos.y);
Vector2 diff = targetPos - planePos;
float dot = planeDir.PerpDot(diff); // perp dot is a.x * -b.y + a.y * b.x
if (dot < 0.0f)
// Target indicator points left
else if (dot > 0.0f)
// Target indicator points right
// Target indicator off (unlikely)

Anyway, that's based on my understanding of the problem, but I may not be getting it exactly.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!