This may depend on how your object is set up, but you can try it and see if it works for you - I find that banking looks and works fine if you carry out your x and y rotations on the whole object, and apply your z rotations on limb 0.
The requirement of the object is that all other limbs except for limb 0 must be children of another limb, or of limb 0.
If you have my plug-ins installed (they're free!), then you can compile this code I wrote a while back as a trial:
sync on
sync rate 60
autocam off
LoadPlayerShip(1)
LoadCourse(1)
global Turn as float = 0.0
global Speed as float = 0.0
repeat
` CollectInput()
HandleTurning()
HandleAcceleration()
set cursor 0, 0
print Turn
UpdateCamera()
sync
until spacekey()
UnloadCourse()
sync off
wait key
end
function CollectInput()
` to be completed
endfunction
function HandleTurning()
if leftkey()
if Turn > -3.0 then dec Turn, 0.1
else
if rightkey()
if Turn < 3.0 then inc Turn, 0.1
else
if Turn <= -0.1
inc Turn, 0.1
else
if Turn >= 0.1
dec Turn, 0.1
else
Turn = 0.0
endif
endif
endif
endif
yrotate object 1, wrapvalue( object angle y(1) + Turn )
rotate limb 1, 0, 0.0, 0.0, Turn * -6
endfunction
function HandleAcceleration()
if upkey()
if Speed < 5.0 then inc Speed, 0.02
else
Speed = Speed * 0.95
if Speed < 0.001 then Speed = 0.0
endif
move object 1, Speed
endfunction
function UpdateCamera()
position camera object position x(1), object position y(1), object position z(1)
rotate camera 20.0, object angle y(1), 0.0
move camera -40.0
endfunction
function LoadPlayerShip(ObjectId as integer)
local TmpObject as integer
local TmpMesh1 as integer
local TmpMesh2 as integer
local TmpMesh3 as integer
TmpObject = find free object()
TmpMesh1 = find free mesh()
make object cube TmpObject, 4.0
make mesh from object TmpMesh1, TmpObject
delete object TmpObject
TmpMesh2 = find free mesh()
make object box TmpObject, 20, 4, 10
make mesh from object TmpMesh2, TmpObject
delete object TmpObject
TmpMesh3 = find free mesh()
make object box TmpObject, 3, 3, 5
make mesh from object TmpMesh3, TmpObject
delete object TmpObject
begin new object
Base = add new limb()
Body = add new limb from mesh(TmpMesh2)
set new limb name "Body"
set new limb parent Base
set new limb offset 0.0, 0.0, -5.0
set new limb color rgb(255, 0, 0)
Neck = add new limb from mesh(TmpMesh3)
set new limb name "Neck"
set new limb parent Body
set new limb offset 0.0, 0.0, 7.0
Head = add new limb from mesh(TmpMesh1)
set new limb name "Head"
set new limb parent Neck
set new limb offset 0.0, 0.0, 4.4
set new limb color rgb(0, 255, 0)
finish new object ObjectId
place object in group ObjectId, 1
delete mesh TmpMesh1
delete mesh TmpMesh2
delete mesh TmpMesh3
endfunction
function LoadCourse(CourseId as integer)
local i as integer
for i = 101 to 300
make object cube i, rnd(2)+1
place object in group i, 2
position object i, rnd(500)-250, 0.0, rnd(500)-250
next
endfunction
function UnloadCourse()
delete objects 101, 1000
endfunction
It needs my plug-ins for the construction of the players ship.