Turning To Face Objects
Blitz3D Forums/Blitz3D Programming/Turning To Face Objects
| ||
DONT SHOUT AT ME!!!! I know there's like a million and one other topics all concerning the same principle, but they just get over-complicated for what I want ((Really - it is dead simple ;-) ) All I need is code to slowly align (by +/- 'ONETORQUE') an object called ONEPivot to face the same way as a mesh called ONEBATMesh I also need to know whether the value is +ve or -ve each loop. That's it!!!! sorry, can anyone provide this using the nomenclature described above??? |
| ||
Try this ...Function align( Entity, Target, Smooth# ) dp# = LIMIT ( DeltaPitch( Entity , Target ) , -Smooth , Smooth ) dy# = LIMIT ( DeltaYaw( Entity , Target ), -Smooth , Smooth ) TurnEntity Entity, dp , dy , 0 End Function ;=========================== ;=========================== ;=========================== Function LIMIT#( q# , low# , hi# ) If q < low q = low If q > hi q = hi Return q End Function Just call this ... align( ONEpivot, ONEBATmesh, ONEtorque ) |
| ||
Thanks Stevie - I totally forgot about the DeltaYaw command... I think I need to change the end section to q=Sgn(LIMIT) Return q but that's great what you've done thanks!!! |
| ||
Not really if you just set smooth# to 1. Glad to help. |
| ||
If KeyDown(200) Then ONEspeed#=onespeed#+ONEacceleration# If ONESpeed#>ONEMaxspeed Then ONESpeed#=ONEMaxSpeed If Not KeyDown(200) Then ONEspeed#=(ONEspeed#-(friction#/100)) If ONEspeed#<0 Then ONEspeed#=0 TurnEntity ONEBATMesh,0,15*(KeyDown(203)-KeyDown(205)),0 align ( ONEpivot, ONEBATmesh, ONEtorque# ) MoveEntity ONEPivot,0,0,ONEspeed# PositionEntity ONEBATMesh,EntityX#(ONEPivot),EntityY#(ONEPivot),EntityZ#(ONEPivot),1 Here's my code... Unless it's VERY slow (but the TORQUE value is set at 8 (compared to the 15 in the turnentity command) by default) it doesn't seem to turn at all... |
| ||
AHhhhh - Sorry misunderstanding... The Code will align my mesh to FACE the pivot. I need it to eventually face the SAME way... |
| ||
I can fix it by adding another pivot in front of the existing one (i.e. always where it is facing by parenting) and substitute thaat. Thanks for your help, though :-) |
| ||
could always just use aligntovector() and transformvector() to do the job with no seperate entities. |
| ||
I could... but that would require some understanding of how to use those commands effectively! hehe |