I combined the animation tutorial with my game engin and i can get the 2 x files to apend but i just cant seem to find the right location for the stage<>oldstage if loop, iv tried in the mian preogram before i call move player, after move player , and even i nthe move player function, obviously im missing the obvious and will continue to fiddle but if you can find the probelm before me that be peachy
`--------------
`player loading
`--------------
`data for player position
restore data_player_positions
`make a temporary player object
for id=1 to 2
make object cube id,500
hide limb id,0
rem Load 3D object and append walking data to it
`LOAD OBJECT "player/WraithIdlex.x",10+id
LOAD OBJECT "player/WraithIdlex.x",10+id : APPEND OBJECT "player/WraithWalkx.x",10+id,20
load image "player/wholelowX.bmp",3
texture object 10+id,3
scale object 10+id,600,600,600
`YROTATE OBJECT 1,180 : FIX OBJECT PIVOT 1
rem Loop 3D object animation from 0 to 20 (idle)
LOOP OBJECT 10+id,0,19 : SET OBJECT SPEED 10+id,120
glue object to limb 10+id,id,0
position object 10+id,0,300,0
`work out position
read xPos#
read zPos#
yPos#=get ground height(1,xPos#,zPos#)
`work out angle
read yAng
`update the player position
position object id,xPos#,yPos#,zPos#
yrotate object id,yAng
friction#(id)=0.80
moveDist#(id)=6.065
xSpeed#(id)=0
zSpeed#(id)=0
next id
`---------
`MAIN LOOP
`---------
main:
do
`get keyboard input for movement
if upkey()=1 then forward=1 else forward=0
if downkey()=1 then backward=1 else backward=0
if leftkey()=1 then left=1 else left=0
if rightkey()=1 then right=1 else right=0
`update the player
move_player(1,forward,backward,left,right)
rem If character action changes
IF stage<>oldstage
IF stage=0
SET OBJECT FRAME 10+id,0.0
LOOP OBJECT 10+id,0,19
SET OBJECT SPEED 10+id,10
ENDIF
IF stage=1
SET OBJECT FRAME 10+id,305.0
LOOP OBJECT 10+id,20,59
SET OBJECT SPEED 10+id,40
ENDIF
oldstage=stage
ENDIF
`update the camera
chase_cam(1)
`update the screen
sync
loop
part two the player function
`-------------------------
`move the specified player
`-------------------------
function move_player(id,forward, backward, left, right)
`----------------------------------
`get the required object properties
`----------------------------------
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
yAng#=object angle y(id)
`-----------------------
`sort out basic movement
`-----------------------
`apply forward movement
if forward=1
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#,moveDist#(id)*1)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#,moveDist#(id)*1)
endif
`apply backward movement
if backward=1
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#,moveDist#(id)*-1)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#,moveDist#(id)*-1)
endif
`apply left rotation
if left=1
yrotate object id,wrapvalue(yAng#-4)
endif
`apply right rotation
if right=1
yrotate object id,wrapvalue(yAng#+4)
endif
`apply jump
newyPos#=object position y(id)+400
if spacekey()=1
while newyPos#>yPos#
yPos#=yPos#+10
chase_cam(1)
endwhile
endif
`--------------------------------------------------
`sort out friction and other physics related things
`--------------------------------------------------
`work out value with friction
xSpeed#(id)=xSpeed#(id)*friction#(id)
zSpeed#(id)=zSpeed#(id)*friction#(id)
`add gravity value
ySpeed#(id)=ySpeed#(id)+gravity#(0)
`work out the new position
xPos#=xPos#+xSpeed#(id)
zPos#=zPos#+zSpeed#(id)
yPos#=yPos#-ySpeed#(id)
`collision
if xPos#>99995 then xPos#=99995
if zPos#>99995 then zPos#=99995
if xPos#<5 then XPos#=5
if zPos#<5 then zPos#=5
`work out the height of the character
if yPos#<get ground height(1,xPos#,zPos#)
ySpeed#(id)=0
yPos#=get ground height(1,xPos#,zPos#)
`------------------------------
`tilt the vehicle to the ground
`------------------------------
distVal#=1.2
`work out the positions of the front, back, left and right of the vehicle
ang#=yAng# : frontX#=newxvalue(xPos#,ang#,distVal#) : frontZ#=newzvalue(zPos#,ang#,distVal#)
ang#=yAng#+180 : backX#=newxvalue(xPos#,ang#,distVal#) : backZ#=newzvalue(zPos#,ang#,distVal#)
ang#=yAng#+90 : leftX#=newxvalue(xPos#,ang#,distVal#) : leftZ#=newzvalue(zPos#,ang#,distVal#)
ang#=yAng#-90 : rightX#=newxvalue(xPos#,ang#,distVal#) : rightZ#=newzvalue(zPos#,ang#,distVal#)
`work out the different heights
frontHeight#=get ground height(1,frontX#,frontZ#)
backHeight#=get ground height(1,backX#,backZ#)
leftHeight#=get ground height(1,leftX#,leftZ#)
rightHeight#=get ground height(1,rightX#,rightZ#)
`work out tilt values
xAng#=curveangle((backHeight#-frontHeight#)*30,object angle x(id+10),5)
zAng#=curveangle((leftHeight#-rightHeight#)*30,object angle z(id+10),5)
`update the vehicle rotation
rotate object id+10,xAng#,180,zAng#
`-----------------
`slide down slopes
`-----------------
xMoveDist#=(backHeight#-frontHeight#)/3
zMoveDist#=(leftHeight#-rightHeight#)/3
`adjust forward/ backward momentum
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#,xMoveDist#)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#,xMoveDist#)
`adjust left/ right momentum
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#-90,zMoveDist#)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#-90,zMoveDist#)
endif
`reposition the player object
position object id,xPos#,yPos#,zPos#
endfunction