Okay - I made a set of funstion that can do animation targeting for our elephant character. It sets up an array of values like so:
global dim Elephant_Anim_Targets(5,5)
Function InitElephantAnims
`Set animation target values
target_info_null = 0
anim_state_walking = 1
anim_state_walk2stand = 2
anim_state_idle = 3
anim_state_bellow = 4
anim_state_stand2walk = 5
Elephant_anim_target = anim_state_idle
Elephant_anim_state = anim_state_walking
counter = 1
`Set animation targets for walking
Elephant_Anim_Targets(anim_state_walking, anim_state_walking) = target_info_null
Elephant_Anim_Targets(anim_state_walking, anim_state_walk2stand) = anim_state_walk2stand
Elephant_Anim_Targets(anim_state_walking, anim_state_idle) = anim_state_walk2stand
Elephant_Anim_Targets(anim_state_walking, anim_state_bellow) = anim_state_walk2stand
Elephant_Anim_Targets(anim_state_walking, anim_state_stand2walk) = anim_state_walk2stand
`Set animation targets for walk to stand
Elephant_Anim_Targets(anim_state_walk2stand, anim_state_walking) = anim_state_stand2walk
Elephant_Anim_Targets(anim_state_walk2stand, anim_state_walk2stand) = target_info_null
Elephant_Anim_Targets(anim_state_walk2stand, anim_state_idle) = anim_state_idle
Elephant_Anim_Targets(anim_state_walk2stand, anim_state_bellow) = anim_state_bellow
Elephant_Anim_Targets(anim_state_walk2stand, anim_state_stand2walk) = anim_state_stand2walk
`Set animation targets for idle
Elephant_Anim_Targets(anim_state_idle, anim_state_walking) = anim_state_stand2walk
Elephant_Anim_Targets(anim_state_idle, anim_state_walk2stand) = anim_state_stand2walk
Elephant_Anim_Targets(anim_state_idle, anim_state_idle) = target_info_null
Elephant_Anim_Targets(anim_state_idle, anim_state_bellow) = anim_state_bellow
Elephant_Anim_Targets(anim_state_idle, anim_state_stand2walk) = anim_state_stand2walk
`Set animation targets for bellow
Elephant_Anim_Targets(anim_state_bellow, anim_state_walking) = anim_state_stand2walk
Elephant_Anim_Targets(anim_state_bellow, anim_state_walk2stand) = anim_state_stand2walk
Elephant_Anim_Targets(anim_state_bellow, anim_state_idle) = anim_state_idle
Elephant_Anim_Targets(anim_state_bellow, anim_state_bellow) = target_info_null
Elephant_Anim_Targets(anim_state_bellow, anim_state_stand2walk) = anim_state_stand2walk
`Set animation targets for stand to walk
Elephant_Anim_Targets(anim_state_stand2walk, anim_state_walking) = anim_state_walking
Elephant_Anim_Targets(anim_state_stand2walk, anim_state_walk2stand) = anim_state_walk2stand
Elephant_Anim_Targets(anim_state_stand2walk, anim_state_idle) = anim_state_walk2stand
Elephant_Anim_Targets(anim_state_stand2walk, anim_state_bellow) = anim_state_walk2stand
Elephant_Anim_Targets(anim_state_stand2walk, anim_state_stand2walk) = target_info_null
EndFunction
The variable is global and this part works all good and well. And yes, all the anim_state_whatever variables have been set and they work.
I then have another function that does that sets the animation and changes animation states when needed.
Note: The model file loaded contains all the animations - the frame numbers are hard coded.The function is as follows:
function AnimateElephant
still = 1
`------------------------------------Elephant Animations-----------------------------------
if elephant_anim_state=anim_state_walking
`if not playing then play
if counter = 1
loop object id_elephant, 0, 146
counter = 0
endif
still = 0
`change anim if needed and possible
if object frame(id_elephant)>144 and object frame(id_elephant)0
elephant_anim_state = Elephant_anim_targets(elephant_anim_state, Elephant_anim_target)
counter = 1
still = 1
endif
endif
`-------------------------------------------Elephant walk to stand-------------------------------------------
if elephant_anim_state= anim_state_walk2stand
`if not playing then play
if counter = 1
play object id_elephant, 146, 183
counter = 0
endif
`change anim if needed and possible
if object frame(id_elephant)>182 and object frame(id_elephant)0
elephant_anim_state = Elephant_anim_targets(elephant_anim_state, elephant_anim_target)
counter = 1
endif
endif
`-------------------------------------------Elephant idle----------------------------------------------------
if elephant_anim_state=anim_state_idle
`if not playing then play
if counter = 1
loop object id_elephant, 184, 329
counter = 0
endif
`change anim if needed and possible
if object frame(id_elephant)>328 and object frame(id_elephant)0
elephant_anim_state = Elephant_anim_targets(elephant_anim_state, elephant_anim_target)
counter = 1
endif
endif
`----------------------------------------Elephant stand to walk----------------------------------------------
if elephant_anim_state=anim_state_bellow
`if not playing then play
if counter = 1
play object id_elephant, 330, 501
counter = 0
endif
if object frame(id_elephant)>369 and object frame(id_elephant)500 and object frame(id_elephant)0
elephant_anim_state = Elephant_anim_targets(elephant_anim_state, elephant_anim_target)
counter = 1
endif
endif
`-------------------------------------------Elephant Bellow--------------------------------------------------
if elephant_anim_state=anim_state_stand2walk
`if not playing then play
if counter = 1
play object id_elephant, 501, 530
counter = 0
endif
`change anim if needed and possible
if object frame(id_elephant)>529 and object frame(id_elephant)0
elephant_anim_state = Elephant_anim_targets(elephant_anim_state, elephant_anim_target)
counter = 1
still = 0
endif
endif
endfunction still
Then i run the function in the main loop like this:
elephant_still = AnimateElephant()
`do path following stuff
But it doesn't work. It is supposed to go from walking to walk2stand to idle, but it doesn't. Can anyone nitpick my (rather messy) code and help me find the error in my ways?
"But we couldn't do that Mr Flibble," questioned Rimmer. "Who'd clean up the mess?"
Twin P4 Xeon 2.0 Ghz, GeForce Quadro4 XGL 128MB, 1Gb DDR RAM, Twin 19" Flat Screens
