Turning To Face Objects

Blitz3D Forums/Blitz3D Programming/Turning To Face Objects

_PJ_(Posted 2004) [#1]
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???


Stevie G(Posted 2004) [#2]
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 )


_PJ_(Posted 2004) [#3]
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!!!


Stevie G(Posted 2004) [#4]
Not really if you just set smooth# to 1. Glad to help.


_PJ_(Posted 2004) [#5]
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...


_PJ_(Posted 2004) [#6]
AHhhhh - Sorry misunderstanding...

The Code will align my mesh to FACE the pivot.

I need it to eventually face the SAME way...


_PJ_(Posted 2004) [#7]
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 :-)


poopla(Posted 2004) [#8]
could always just use aligntovector() and transformvector() to do the job with no seperate entities.


_PJ_(Posted 2004) [#9]
I could... but that would require some understanding of how to use those commands effectively! hehe