DeltaRoll - anyone?
Blitz3D Forums/Blitz3D Programming/DeltaRoll - anyone?
| ||
Can some clever person write a DeltaRoll function that actually works? Blitz has built in DeltaYaw and DeltaPitch but no DeltaRoll function... |
| ||
DeltaPitch/Yaw tells you whether entity2 is below/above/left/right entity1. What are you wanting "DeltaRoll" to do? |
| ||
To turn a homing missile towards the player. Any code examples would be VERY helpful! |
| ||
You can do that with DeltaPitch and DeltaYaw. DeltaPitch tells you if the target is above (+) or below (-) the missile. DeltaYaw is used to determine whether the target is to the left (-) or right (+) of the missile. So for example, if DeltaYaw returns -10, you know that your missile needs to turn to the left. If DeltaPitch returns 40 then you need to increase the pitch of the missile. If DeltaPitch and DeltaYaw were both 0, (which is not likely since they both return floats, but it keeps the explanation simple), then the missile is pointing directly at the target object. Hope this helps. [Edit] As for DeltaRoll - you don't need this. Just keep your EntityRoll for the missile at zero. Can do that with RotateEntity missile,EntityPitch(missile),EntityYaw(missile),0[,true] |
| ||
Best to stick with the deltayaw/ pitch functions but if you're missile moves in a similar way to Elite ships (i.e. Pitch and Roll only ) then here's a simple function I knocked up. Hit space to position the target randomly. Stevie Graphics3D 640,480,16,1 Global Camera = CreateCamera() : PositionEntity Camera, 0, 0, -30 Global Ship = CreateCone(): ScaleMesh Ship, 1, 2, 1 : EntityColor Ship, 0,0,255 Global Target = CreateCube() : EntityColor Target,255,0,0 Repeat If KeyHit( 57 ) PositionEntity target, Rand(-20,20 ), Rand(-20,20 ), 10 EndIf DR# = DELTAroll( Ship, Target ) TurnEntity ship, 0, 0, DR * .01 RenderWorld() Text 0,0,DR Flip Until KeyDown(1) ;================================================================================= ;================================================================================= ;================================================================================= Function DELTAroll#( Source , Target ) TFormPoint 0,0,0 , Target, Source Return VectorYaw ( TFormedX() , 0 , TFormedY() ) End Function Stevie |
| ||
Stevie G, awesome!!! one for the code archieves methinks... |