Major animation problem!

Blitz3D Forums/Blitz3D Programming/Major animation problem!

Rage_Matrix(Posted 2004) [#1]
Hi all,

I'm in desperate need of help here....usually I've some sort of idea about whats wrong with my code (doesn't help that Blitz has no step-through debugger break-point functionality), but this has got me stumped.

I'm writing the animation control code for my zombie and it *should*, when you press 1 to commence the walk cycle, start walking. The sequence is like this....

To start walking...

1. Change mode from IDLE to WALK.
2. Raise arms.
3. Once this has finished, start WALK START animation.
4. Once this has finished, loop WALK CYCLE.

What happens at the moment is that it finishes idle, switches to raising arms and then goes back to idle and *then* starts the walk normally. I can't for the life of me figure this one out. I think its something to do with this part of the code...

Function ZOMBIE_ProcessAnimation%(tZ.Zombie)
	Local CurrFrame% = 0
	Local SeqName$ = ""
	Local EndFrame% = 0
	
	If (tZ = Null) Then
		Return False
	Else
		CurrFrame% = ZOMBIE_GetCurrentFrame(tZ)
		SeqName$ = ZOMBIE_GetAnimSequenceString(tZ\AnimSequence%)
		EndFrame% = ZOMBIE_GetEndFrame%(SeqName$)
		Select tZ\AnimMode%
			Case ZOMBIE_ANIM_MODE_IDLE:
				For tAS.XMLAnimSequence = Each XMLAnimSequence
					If (Lower(tAS\owner$) = "zombie" And Lower(tAS\name$) = Lower(SeqName$)) Then
						Select tZ\NextAnimMode%
							Case ZOMBIE_ANIM_MODE_WALK:
								tZ\AnimMode% = tZ\NextAnimMode%
								tZ\AnimSequence% = ZOMBIE_ANIM_SEQ_ARMS_UP
								If (Not ZOMBIE_SetAnimationSequence(tZ, tZ\AnimSequence%)) Then
									DebugLog "Error setting walk"
								EndIf
						End Select
					EndIf
				Next
			Case ZOMBIE_ANIM_MODE_WALK:
				Select tZ\AnimSequence%
					Case ZOMBIE_ANIM_SEQ_ARMS_UP:
						If (Not MD2Animating(tZ\ZombieEnt%)) Then
							If (Not ZOMBIE_SetAnimationSequence(tZ, ZOMBIE_ANIM_SEQ_WALK_START)) Then
								DebugLog "Error setting walk start"
							End If
						EndIf
					Case ZOMBIE_ANIM_SEQ_WALK_START:
						If (Not MD2Animating(tZ\ZombieEnt%)) Then
							ZOMBIE_SetAnimationSequence(tZ, ZOMBIE_ANIM_SEQ_WALK_CYCLE)
						EndIf
				End Select
		;	Case ZOMBIE_ANIM_MODE_ATTACK
		;	Case ZOMBIE_ANIM_MODE_DAMAGE
		;	Case ZOMBIE_ANIM_MODE_DIE
		;	Case ZOMBIE_ANIM_MODE_RESURRECTION
		;	Case ZOMBIE_ANIM_MODE_FEED
		End Select
		Return True
	EndIf
End Function


The concept is simple really.....the zombie has Modes for whichever action you perform on the keyboard. This then fires off one or more animation sequences (depending on whether they're looped or not). Thats pretty much it, but after raising its arms, the animation resets and plays the entire thing from frame zero and then does what its supposed to do.

I've included the complete code here (975kb): -

http://www.tronsoftware.dabsol.co.uk/downloads/ZombieAnimation.zip

Can some kind soul download this and have a look through the code and tell me what I'm doing wrong? The XML loading for the frames should be okay (thanks Mordy :)), but the animation control code is borked. AFAIK, all the frames are correctly numbered (checked in my modeller).

Argh....help?

Thanks all.