animation controls
Blitz3D Forums/Blitz3D Programming/animation controls
| ||
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 |
| ||
It seems to be a problem with the way you handle the idle flag. Well, I didn't read your code carefully, I suggest right away: restart from scratch :) concerning the keys handler. Here's what I'd do:idle=1 if keydown(walk) if jumping=0 if walking=0 walking =1 animate joe,walk_seq endif idle=0 swimming=0 whatever=0 isbored=0 endif moveentity joe,0,0,1 endif if keyhit(jump) if jumping=0 jumping =1 animate joe,jump_seq jump_force#=1.1 isbored=0 idle=0 swimming=0 whatever=0 walking=0 endif endif if jumping=1 jump_force=jump_force- .1 if jump_force < -1.1 then jumping=0 ; add collision check! endif if idle=1 if isbored=0 animate joe,idle_seq isbored=1 endif endif translateentity joe,0,gravity#+jump_force#,0 ; gravity Well, basicly do the following: set idle to true check all possible keys - and set idle to false if the user makes any action in the end ask if idle is still true and play the idle animation if required. |
| ||
I will have a look that Jfk and get back to you, cheers, its been driving me mad . flags seem to confuse me the most for some reason and this stuff makes your brain hurt after a while. if it was just a case of walk and walk back it would be easy, but the more controls I have the more they seem to confuse and act against each other. |
| ||
well that hit the spot after an hour or two of tweaking I have sorted all the bugs out apart from a problem with jumping. will look at that tomorrow its just not playing its full sequence, but all the nastier bug are fixed now. thanks for that jfk. it was all in the flags he he |