Slow turn to point at entity?
Blitz3D Forums/Blitz3D Programming/Slow turn to point at entity?| 
 | ||
| Hey guys. Is there any way to slowly turn an entity to point it at another? I guess it'd have to be something with vectors, and I'm still a novice at that. I'm putting it together for the AI for my space game engine, and I tried for an hour without success, then got frustrated and fixed a few other things, but whenever I ran my program, my annoying AI bot was bouncing all over the place. Help! | 
| 
 | ||
| use this and adopt for any other axis you need Function EntityPoint( Source , Target, MaxYawSpeed# , MaxPitchSpeed# ) DY# = DeltaYaw( Source, Target ) If Abs( DY ) > MaxYawSpeed DY# = Sgn( DY ) * MaxYawSpeed ;DP# = DeltaPitch( Source, Target ) ;If Abs( DP ) > MaxPitchSpeed DP = Sgn( DP ) * MaxPitchSpeed TurnEntity Source, 0 , DY , 0 End Function | 
| 
 | ||
| Another one ;Get Vector to the target Local Dx# = EntityX( target, True ) - EntityX( source ) Local Dy# = EntityY( target, True ) - EntityY( source ) Local Dz# = EntityZ( target, True ) - EntityZ( source ) ;Align source to the target vector AlignToVector source, Dx, Dy, Dz, 3, 0.2 ; 3=Axis, 0.2=Rate(turning speed) ;Move the source forward MoveEntity source, 0, 0, speed# | 
| 
 | ||
| Thanks guys! Both of those worked great! I didn't even know there was a DeltaYaw function. I wonder how I missed that in the command reference... | 
| 
 | ||
| I think it's a fairly new command, so it might not be in your documentation pack. I believe you can download newer versions. |