entity tracking (sort of a radar)

Blitz3D Forums/Blitz3D Beginners Area/entity tracking (sort of a radar)

stayne(Posted 2008) [#1]
I have a hud and want to have the ability to track selected entities via a small arrow that always points to it. The tricky part is that the arrow needs to rotate...around the center of the screen. Sort of like a compass, with an arrow at the outside edge, in the center of the screen. For example, you select an asteroid and fly away from it. The "compass" rotates and always points to the direction the asteroid is in, even if it is behind the ship. Make sense? I have no idea how to do this, just hoping someone can drum up some code or an idea for me to start with!


Stevie G(Posted 2008) [#2]
Angle# = DeltaYaw( Player , Target )
RotateEntity Arrow, 0,0, Angle



stayne(Posted 2008) [#3]
Thanks Stevie! Remember it's a hud...2D.


GfK(Posted 2008) [#4]
He's still correct.

Your HUD should use 3D sprites and iirc, there's a RotateSprite command which will be perfect for this.

Mixing 2D and 3D is never a good idea.


stayne(Posted 2008) [#5]
I agree GfK, I never mix text or anything else 2d with 3d unless it's a quickie debug type thing. I was just referring to 2d commands. I'm using Draw3D with...

If this\selected = True
Angle# = DeltaYaw( camera , this\mesh )
DrawImage3D(arrow,0,0,0,angle)
EndIf

Not really working. Barely moving, but not as intended I'm sure. Still pluggin.


stayne(Posted 2008) [#6]
Here's a shot of my little space world :). As you can see the arrow barely turns... I took a shot with it above left and below right.






mtnhome3d(Posted 2008) [#7]
a lot of games place the arrow at the side of the screen and it moves around the edges till the object its pointing at is in view, then it zeros in on the target and turns into a "locked on" symbol around the target.


Stevie G(Posted 2008) [#8]
Now that I've seen the screenshot and it's clear your using a sprite library you should probably be using DeltaRoll instead of Deltayaw. All your sprites are likely on the x/y plane , rather than the x/z plane which I originally thought.

It does help to give alot more information - no one is a mind reader here.

Anyway, see function below:

Function DELTAroll#( Source , Target )

	TFormPoint 0,0,0 , Target, Source
	Return VectorYaw ( TFormedX() , 0 , TFormedY() )

End Function



stayne(Posted 2008) [#9]
Thank you Stevie G this works perfectly. My apologies for not explaining fully...

If as\selected = True
angle = DELTAroll#(camera,as\mesh)
drawimage3d(arrow,0,0,0,-angle)
EndIf