I made this sample code to help in another tread with turret angles, but this seems to be what you might need. Uses a revolute joint and works like a stepper/servo motor where you set the target angle and it travels to that angle by the shortest angular path.
Edit: noticed it uses EZ Rotate.
Sync On
Sync Rate 60
Phy Start
Make Object box 1, 10,10,100
Phy Make Rigid Body Dynamic Box 1
Make Object box 2, 50,50,60
Phy Make Rigid Body Dynamic Box 2
Phy Set Rigid Body Kinematic 2,1
Phy Make Revolute Joint 1,2,1,0,1,0,Object Position X(1),Object Position Y(1),Object Position Z(1)
Autocam Off
position camera 0,100,-400
TurretAngle# = rnd(360)
RotateTurretToAngle# = rnd(360)
Do
EZro_SetupFromObject 1
EZro_FindAxisAngles
TurretAngle# = EZro_GetAxisAngleY()
if Spacekey() and blocktime<timer()
blocktime=timer()+500
RotateTurretToAngle#=rnd(360)
Origin# = TurretAngle#
endif
if (RotateTurretToAngle# - TurretAngle#) >= 180.0 ` Turret has to go from lower to higher angle over zero to get to destination
SetTorque# = (RotateTurretToAngle# - TurretAngle#) - 360.0
else
if (RotateTurretToAngle# - TurretAngle#) <= -180.0 ` Turret has to go from higher to lower angle over zero to get to destination
SetTorque# = (RotateTurretToAngle# - TurretAngle#) + 360.0
else
SetTorque# = RotateTurretToAngle# - TurretAngle# ` turret does not travel over zero angle
endif
endif
text 1,1 ,"Angle differance (Passed to angular velocity): " + str$(int(SetTorque#))
text 1,20,"Random value , rotate turret to this angle : " + str$(int(RotateTurretToAngle#))
text 1,40,"The turrets current angle : " + str$(int(TurretAngle#))
text 1,60,"The turrets angle before we pressed space : " + str$(int(Origin#))
SetTorque#=SetTorque#*.05 ` smoother movement equivalent to SetTorque#/20, but multiplication is faster =)
Phy Set Rigid Body Angular velocity 1,0,SetTorque#,0
Phy Update
sync
loop
Regards