animation controls

Blitz3D Forums/Blitz3D Programming/animation controls

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I am still struggling with the animation controls for my demo.
it more or less works how I want , but some things are just getting me down.
problems are.
1. can't get jump and run to work. standing jump works fine.
if I run and jump and try to assign an animation , it only plays the first frame then defaults back to run

2 major bug. if I am running , then stop pressing the run key, but press another key beofe I let go, the character keeps running on the spot.
so if I want to stop quickly to hit an enemy , the run sequence is running still, not the hit sequence.
3. jumping again. if I press keyhit(184) for jump, the animation only plays as long as my finger is pressed. i want to press the key then the animation to play once through whether the key is pressed or not.
4 dying works, but the body is not lying flat on the ground, but at about a 30 degree angle.
posssible collision problem?

anyway here is the code so far, would really appreciate some help on this. my brain hurts. i could have used 'else' a lot more , but wanted to keep it readable and simple to undertsand

;list of sequences
player_model=LoadAnimMesh( "models\pearman.b3d" )
walk=ExtractAnimSeq (player_model,0,30);sequence 1
idle= ExtractAnimSeq (player_model,31,45);sequence 2
jump=ExtractAnimSeq (player_model,46,51);sequence 3
still=ExtractAnimSeq (player_model,46,46);sequence 4
turnleft=ExtractAnimSeq (player_model,51,54);sequence5
turnright=ExtractAnimSeq (player_model,51,54);sequence 6
dying1=ExtractAnimSeq (player_model,54,57);sequence 7
bigslap=ExtractAnimSeq (player_model,59,69);sequence 8
threaten=ExtractAnimSeq (player_model,70,80);sequence 9


If KeyDown(200)

If AnimSeq(p\model)<>1

Animate p\model,1,.7,1 ;walking

EndIf
MoveEntity p\entity,0,0,.15

EndIf


;EndIf

;walking backward ############################################################

If KeyDown(208)

If AnimSeq(p\model)<>1
Animate p\model,1,-.7,1,.5 ;walking backwards
EndIf
MoveEntity p\entity,0,0,-.1

EndIf



;turning#####################################################################

If KeyDown(203)
If AnimSeq(p\model)<>1
If AnimSeq(p\model)<>5
Animate p\model,1,.05,5 ;turnleft

EndIf
EndIf

TurnEntity p\entity,0,2,0

EndIf

If KeyDown(205)

If AnimSeq(p\model)<>1
If AnimSeq(p\model)<>6

Animate p\model,1,.05,6,5 ;turnright


EndIf
EndIf

TurnEntity p\entity,0,-2,0

EndIf


;jumping ############################################################

ty#=EntityY(p\entity);jumping from castle demo
y_vel#=(ty-p\player_y)
p\player_y=ty


If KeyHit(184) And EntityCollided(p\entity,TYPE_SCENERY)>1
y_vel=1

;If AnimSeq(p\model)<>1
If AnimSeq(p\model)<>3
Animate p\model,3,.1,3 ;jump
EndIf

Else

y_vel=y_vel-.05 ;2


EndIf

TranslateEntity p\entity,0,y_vel,0



;idle ############################################################

;idle - only seemed to work doing it this way- suugestions?
If Not KeyDown(200)

If Not KeyDown(203)
If Not KeyDown(205)

If Not KeyDown(208)

If Not KeyDown(184)
If Not KeyDown(157)

idleflag=True



EndIf
EndIf
EndIf
EndIf
EndIf
EndIf

If idleflag=True
If AnimSeq(p\model)<>2
Animate p\model,1,.1,2,7;idle sequence

EndIf
EndIf

;idle ############################################################

If KeyHit(157)


If AnimSeq(player1\model)<>1
If AnimSeq(player1\model)<>8

Animate player1\model,3,.24,8;bigslap

If EntityDistance(enemy1\model1,player1\model)<6

MoveEntity enemy1\model1,0,.3,-.5


PlaySound(Punch)

enemy1\health =+enemy1\health-10


EndIf
EndIf
EndIf
EndIf