I'm having a little trouble in accurately rotating limbs. The first section of code is used within a function to move a tank around the landscape. This works ok and gives a nice slow rotation using the curveangle command.
destxpos#=object position x(tank(1).TargetObj)
destzpos#=object position z(tank(1).TargetObj)
distance=sqrt((destxpos#-tank(1).xpos#)^2+(destzpos#-tank(1).zpos#)^2)
angle1#=destxpos#-tank(1).xpos#
angle2#=destzpos#-tank(1).zpos#
totalangle#=wrapvalue(atanfull(angle1#,angle2#))
zangle#=curveangle(object angle y(tank(1).obj),totalangle#,1.01)
tank(1).xpos#=newxvalue(tank(1).xpos#,zangle#,tankspeed#)
tank(1).zpos#=newzvalue(tank(1).zpos#,zangle#,tankspeed#)
position object tank(1).obj,tank(1).xpos#,0,tank(1).zpos#
yrotate object tank(1).obj,zangle#
This section of code is used to slowly rotate the turret (limb 3) to point towards the object called cam_obj.
function tankfire(no)
xpos#=object position x(tank(no).Obj)
zpos#=object position z(tank(no).Obj)
destxpos#=object position x(cam_obj)
destzpos#=object position z(cam_obj)
distance=sqrt((destxpos#-xpos#)^2+(destzpos#-zpos#)^2)
angle1#=destxpos#-xpos#
angle2#=destzpos#-zpos#
total#=wrapvalue(atanfull(angle1#,angle2#))
zangle#=curveangle(limb angle y(tank(no).obj,3),total#,1.01)
rotate limb tank(no).Obj,3,0,zangle#,0
endfunction
The problem is it doesn't and the turret points in completly the wrong direction. When i reset the y rotation of the tank back to 0 then the turret will point towards the Cam_obj. I think i understand why its doing this and that somehow i need to add the y rotation of the tank to the starting rotation point of the turret. The question is How to do this and successfully use the curveangle command to give a nice slow rotation.
Any answers/advice would be more then welcome.