Ok now I have rewritten the code from scratch to make the animation play. The move commands work well and the attack command plays the animation correctly. I even have a so called random move that plays if you touch no controls for about 10 seconds or so. The problem is that some of the animation will not play using the play object command. Here is the entire code using the Ninja.x models from dark matter 1.
backdrop on
color backdrop rgb(128,128,128)
sync on
hide mouse
`Sets the display up
`SET DISPLAY MODE 1024, 768, 32
`maximize window
set camera range 1, 35000
`Creating the background sky_Box stuff
` object ID for the skybox object:
intBoxNum = 200
GOSUB SKYBOX_LOADER
`create matrix stuff
GOSUB LOAD_MATRIX
`Create the Player stuff
load object "Ninja\H-Ninja-Idle.x",1
append object "Ninja\H-Ninja-Fidget.x",1,26
append object "Ninja\H-Ninja-Impact.x",1,76
append object "Ninja\H-Ninja-Die.x",1,86
append object "Ninja\H-Ninja-Attack1.x",1,136
append object "Ninja\H-Ninja-Move.x",1,161
scale object 1, 300,300,300
`rotate object 1,0,180,0
position object 1,50,2,50
`-------------------------------------------
`set up a variable for the aminate sequence
`-------------------------------------------
moving = 0
attack = 0
startFrameIdle = 1
endframeIdle = 25
startFrameFidget = 26
endFrameFidget = 75
startFrameImpact = 76
endFrameImpact = 85
startFrameDie = 86
endFrameDie = 135
startFrameAttack = 136
endFrameAttack = 160
startFrameMove = 161
endFrameMove = 185
startTimer# = timer()
endTimer# = 0
objectFrame = 0
health = 500
`------------------------------------------------------------------------------
`Main Loop
`------------------------------------------------------------------------------
do
yAng=object angle y(1)
`---------------------
` Control sequence
`---------------------
if upkey()= 1 and attack = 0 and die = 0: stop object 1 : move object 1,-0.25 : moving = 1 : gosub animateforward : startTimer# = timer() : health = health - 1 : endif `object playing "Move" in forward motion
if downkey() = 1 and attack = 0 and die = 0: stop object 1 : move object 1,0.25 : moving = 1 : gosub animatebackward : startTimer# = timer() : health = health - 1 : endif `object playing "Move" in reverse motion
if leftKey()=1 and attack = 0 and die = 0
yrotate object 1, wrapvalue(yAng-2)
endif
if rightkey()=1 and attack = 0 and die = 0
yrotate object 1, wrapvalue(yAng+2)
endif
if spacekey() = 1 and moving = 0 and die = 0 : attack = 1 : stop object 1 : moving = 1 : play object 1,136,160 : health = health-10 : endif
if object frame(1) = endFrameAttack then moving = 0 : attack = 0 : startTimer# = timer()
if moving = 0 and upkey()=0 and downkey() = 0 and attack = 0 and die = 0
loop object 1,startFrameIdle,endFrameIdle
endif
`Die sequence
if health =< 0 and die = 0
stop object 1 : attack = 1 : moving = 1 : die = 1
endif
if health =< 0 and die = 1
play object 1,87,135`startFrameDie,endFrameDie
startTimer# = timer()
endif
`Timer Loop for Fidget
endTimer# = timer()
if (endTimer# - startTimer#) => 10*1000 and moving = 0 and attack = 0 and die = 0
stop object 1 : moving = 1 : attack = 1 : play object 1,startFrameFidget,endFrameFidget
startTimer# = timer()
endif
if object playing(1) = 0 and moving = 1 and attack = 1
attack = 0
moving = 0
startTimer#=timer()
endif
if inkey$()="r" then health = 500 : attack = 0 : moving = 0 : die = 0 : position object 1,50,2,50 : startTimer# = timer()
`height of object
xPos#=object position x(1)
zPos#=object position z(1)
yPos#=get ground height(1,xPos#,zPos#)
`Simple Collision control so you do not walk off the edge.
if xPos# < 4 then xPos# = 4 : play object 1, startFrameImpact, endFrameImpact
if zPos# < 4 then zPos# = 4 : play object 1, startFrameImpact, endFrameImpact
if xPos# > 1996 then xPos# = 1996 : play object 1, startFrameImpact, endFrameImpact
if zPos# > 1996 then zPos# = 1996 : play object 1, startFrameImpact, endFrameImpact
`update the objects position
position object 1,xPos#,yPos#,zPos#
`update the camera
gosub chase_cam
`Prints object frame # to screen for testing purposes
objectFrame = object frame(1)
set cursor 0,0
print "current frame # = " ; objectFrame
`Prints heath info to screen for testing purposes
print "current health level = " ; health ; " die =";die
sync
loop
`------------------------------------------------------------------------------
`End of Main Loop
`------------------------------------------------------------------------------
`----------------
`Loading the Sky
`----------------
SKYBOX_LOADER:
` REPLACE THE PATHNAME BELOW WITH THE PATH TO THE SKYBOX YOU WISH TO LOAD!
load object "Sky_Box/cielo.x", intBoxNum
set object light intBoxNum, 0
` This SET OBJECT TEXTURE command is critical -- the default mode of zero will leave ugly lines showing
` around the edge of your skybox.
set object texture intBoxNum, 2, 1
` The box size is only 60 3D units cubed. It is designed to be sized, and sized big. So let's do so...
`
scale object intBoxNum, 30000 , 30000, 30000
position object intBoxNum, 0,0,0
`
RETURN
`-------------------
`Loading the Matrix
`-------------------
LOAD_MATRIX:
`this matrix will be 1000 units square and split up into 1000 units (100*100)
make matrix 1,2000,2000,100,100
`set matrix heights
`we will use 2 "for" loops to create the matrix
`the first loop uses the xPoints the second uses the zPoints
for xPoint=0 to 99
for zPoint=0 to 99
`you can make up your on expressions to or RND the numbers
`you can also use a loop to read # already plotted in a file you already created
height=rnd(2)
set matrix height 1,xPoint,zPoint,height
next zPoint
next xPoint
`set the matrix texture
load image "matrixfloor.bmp",1
prepare matrix texture 1,1,2,2
`loop through matrix tiles
for xTile = 0 to 99
for zTile = 0 to 99
`set the matrix tile texture
`the texture is a random #
set matrix tile 1,xTile,zTile,rnd(3)+1
next zTile
next xTile
`we must update the matrix after it has been changed
update matrix 1
RETURN
`------------------
`Chase Camera
`------------------
chase_cam:
`work out the angle of the object being chased
yAng#=wrapvalue (object angle y(1)+180) `change the 180 to change dirction camera will face
`get objects current position
xPos#=object position x(1)
yPos#=object position y(1)
zPos#=object position z(1)
`other varibales
camDist = 10
camHeight = 3
`Work out new position
xCamPos#=newxvalue(xPos#,yAng#,camDist)
zCamPos#=newzvalue(zPos#,yAng#,camDist)
`Work out the camera height
yCamPos#=get ground height (1,xCamPos#,zCamPos#)+camHeight
if yCamPos#<yPos#+camHeight then yCamPos#=yPos#+camHeight
`Update Camera Position
position camera xCamPos#,yCamPos#,zCamPos#
point camera xPos#,yPos#+camHeight,zPos#
return
`--------------------------
`Animating the characters
`-------------------------
animateforward:
if moving = 1 and attack = 0 and die = 0
if frame < startFrameMove then frame = startFrameMove
if frame > endFrameMove then frame = startFrameMove+5
frame = frame+1
set object frame 1, frame
moving = 0
endif
RETURN
animatebackward:
if moving = 1 and attack = 0 and die = 0
if frame < startFrameMove+7 then frame = endFrameMove
if frame > endFrameMove then frame = endFrameMove
frame = frame - 1
set object frame 1, frame
moving = 0
endif
RETURN
animateRandom:
` if moving = 0 and attack = 0 and waitTime = 100
` if frame < startFrameFidget then frame = startFrameFidget
` ` if frame > endFrameFidget then frame = startFrameFidget
` frame = frame + 1 : moving = 1 :
`` set object frame 1, frame
` if frame => endFrameFidget then moving = 0
` endif
RETURN
If someone could look this over and let me know what I am overlooking would be a great help!