• What is your GameDev Story?

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

Recommended Posts

For the life of me I can't figure out how to create a radar for a flight sim type game. Plotting objects based on distance is no big deal. The problem is when the view rotates around the blips stay in the same place. I imagine its something with the view matrix but I have no idea what.

Share on other sites
If I have understood your problem correctly then all you have to do is rotate the blip's position from the center by the same angle that the view is rotated (hope that makes sense). 2D vector rotation looks like this:

x2 = x1*cos(angle) + y1*sin(angle);
y2 = y1*cos(angle) - x1*sin(angle);

Share on other sites
Just calculate the position of the various objects relative to the object that radar is centred around in that object's space (if you camera is located in the front of the plane that the radar is centred around you can do this in view space). Project them on to a 2D plane (e.g. by dropping the z coordinate) and plot on your radar screen.

This assumes you want a head-up radar display, i.e. one where the stuff on the screen directly above the centre is directly in front of the place, if you want something else, so when you rotate your plane the entire display rotates around the centre. If you want the display to stay fixed when you rotate (in which case you'll want a line giving the current heading on the display) just do what I said above, but do it in world space.

Share on other sites
Yeah, I was taking the distance between two objects and then rotating it by the right, up, and forward vectors of the camera (player view). The problem was instead of adding all the pieces together I had a typo and was multiplying some of the parts together.

pos.y = (temp.x*cam.uvec.x)+(temp.y*cam.uvec.y)+(temp.z*cam.uvec.z);

I was doing this:
pos.y = (temp.x*cam.uvec.x)+(temp.y*cam.uvec.y)*(temp.z*cam.uvec.z);

Spend hours messing with it and it was a simple error.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 12
• 15
• 14
• 46
• 22
• Forum Statistics

• Total Topics
634054
• Total Posts
3015275
×