Problems with animation?
Blitz3D Forums/Blitz3D Beginners Area/Problems with animation?
| ||
Hi all, ok, I coded a test demo to try and correctly get my animations working for all models. Problem is, that for some reason when i try to display the walk or run animation, for some reason, it STARTS to do the animation, but then freezes if i hold down the up or down arrow keys, or the W/S keys... Also, if I hold down control and press the space key, he attacks. but then he keeps attacking, and keeps attacking... I need him to NOT freeze, and NOT attack multiple times.. It uses Psionic's Dwarf. Here's the code: Any help is greatly appreciated! :) Thanks! :) |
| ||
Anyone? This is driving me ABSOLUTELY up the wall T_T |
| ||
The thing you need to understand about animating meshes is that if you repeatedly call Animate on the same sequence, the mesh will continuously start from the beginning of the animation sequence and you won't see anything except for the first frame or two. The easiest fix to this problem is to check and see if the current animation sequence is the same sequence as the one you wish to be animating, and only if they are not the same will you call Animate.Function Animate_Player(state) ;Animate the dwarf ONLY if a button is being held OR is being held and another is being pressed If Not KeyDown(42) Or KeyDown(54) If state=s_forwardwalk If AnimSeq(dwarf1) <> walk Animate dwarf1,1,animspeed#,walk,transpose# EndIf EndIf If state=s_backwardwalk If AnimSeq(dwarf1) <> walk Animate dwarf1,1,-animspeed#,walk,transpose# EndIf EndIf Else If state=s_forwardwalk If AnimSeq(dwarf1) <> run Animate dwarf1,1,animspeed#,run,transpose# EndIf EndIf If state=s_backwardwalk If AnimSeq(dwarf1) <> run Animate dwarf1,1,-animspeed#,run,transpose# EndIf EndIf EndIf If state=s_attack If AnimSeq(dwarf1) <> attack Animate dwarf1,1,-animspeed#,attack,transpose# EndIf If Not Animating(dwarf1) state = s_idle EndIf EndIf ;Set idle animation if not animating If state=s_idle If AnimSeq(dwarf1) <> idle Animate dwarf1,1,animspeed#,idle,transpose# EndIf EndIf Return state End Function |
| ||
Ugh! THANK you! It's been driving me nuts for nearly 3 days O_O |