Rotate a Entity slowly to face another

Blitz3D Forums/Blitz3D Programming/Rotate a Entity slowly to face another

Teffo(Posted 2005) [#1]
In my 3D space game, I have some ships attacking other ships. What I have difficulty is rotating the attacker ship slowly over several seconds to face the target ship.

PointEntity is too dramatic and unrealistic.
I can get the Yaw of each, but that does not offer me a solution. Any one have a solution?

Thanks
Teff


RiverRatt(Posted 2005) [#2]
There is some code in the aechives that does this exact thing. not sure exactly where though.


RiverRatt(Posted 2005) [#3]
http://www.blitzbasic.com/codearcs/codearcs.php?code=206

keep looking in that section I think there is another one also.


Teffo(Posted 2005) [#4]
Thank you very much!

I managed to use the function and modify it so the entity turns in a incremental manner. Works very nicely!

Teff


xdiff# = EntityX(id)-EntityX( target)
ydiff# = EntityY(id)-EntityY( target)
zdiff# = EntityZ(id)-EntityZ( target)
dist#=Sqr#((xdiff#*xdiff#)+(zdiff#*zdiff#))
pitch# = ATan2(ydiff#,dist#)
target_yaw# = ATan2(xdiff#,-zdiff#)
shooters_yaw#=EntityYaw(id)
If shooters_yaw# > target_yaw# Then TurnEntity id,0,-1,0
If shooters_yaw# < target_yaw# Then TurnEntity id,0,+1,0
MoveEntity id,0,+Cos(sinvalue)*10,speed#