Radar

Blitz3D Forums/Blitz3D Programming/Radar

Jeroen(Posted 2004) [#1]
First of all, happy new year!!!
/me got very drunk

I have a question.
Because the levels in the game I am making are rather big, I'd like to use a "player radar" where you can see players in your neighbourhood. I use a fixed camera rotation value.



I'd like to project the player coordinates to a radar (HUD) as you can see in the quick mockup picture.

How do turn a position of another player, relative to mine (local player), into an angle that is displayed on a 2D HUD? It uses arrows as you can see.

ps: Eventually I will use the alpha value to display how far away someone is (far away is high alpha value, nearby is opaque value)


Ross C(Posted 2004) [#2]
I'm not too sure what you mean? Can you explain more?


elseano(Posted 2004) [#3]
You could use the entityyaw(entity), entitypitch(entity), and entityroll(entity) functions to figure it out, but i'm not exatly sure what you mean.
For the alpha/distance part, you could use the EntityDistance(src_entity,dest_entity) function, and then entityalpha in combination to have it fade away as enemies etc get further away.
I'm not really sure that this is the stuff you need, so correct me if I'm wrong ;)

ps. Happy New year to you too!
/me got very bored as party I went to was rubbish :P


Jeroen(Posted 2004) [#4]
Hey guys,
Well what I mean is this:

Let's say I am on coordinates
(x,y,z): 200,2,500

And the other player is on:
(x,y,z): 100,2,900

Then I'd like to calculate where the other player is, relative to my position. This should return an angle for my radar arrows (see the green circle that represents the radar. As you can see the arrows represent the location of the other players)


Ross C(Posted 2004) [#5]
Does the radar rotate as the player rotates?


Jeroen(Posted 2004) [#6]
no, the player rotates, but the rader keeps static, as well as the camera.


GfK(Posted 2004) [#7]
I think you'll be needing a combination of DeltaYaw (for the angle) and EntityDistance (to determine how far from the player the 'enemy' is).


Ross C(Posted 2004) [#8]
That makes it easier then :) Just find the location of the other objects, the use:

angle=ATan2(camz-objectz,camx-objectx)

That will give you the angle. I might have mixed up the order: might be objectz-camz. :)


Jeroen(Posted 2004) [#9]
@ GfK: DeltaYAW will help me returning the angle of a entity, but not a entity relative to another one.

@ Ross C: that looks good! I'll try and use that formula! As for myself, I never get good grip on Tan, Cos and Sin...I know *very roughly* what they do, but somehow practical implementations always fails :-)


Ross C(Posted 2004) [#10]
Well, that command will return the angle between two entitys, or 2 points even :)