controlling animations

Blitz3D Forums/Blitz3D Beginners Area/controlling animations

killertomato(Posted 2007) [#1]
Hi,

I was wondering, why is it that when you want to set up an animation to happen on a certain event, such as a key hit, you have to do something like this, taken from the markio example:

If KeyDown(30) ;forward
If p\anim_speed<=0
p\anim_speed=1.75
Animate p\model,1,p\anim_speed
EndIf
MoveEntity p\entity,0,0,1
Else If p\anim_speed ;stop animating
p\anim_speed=0
Animate p\model,0
EndIf

instead of just:

If KeyDown(30)
p\anim_speed = 1.75
Animate p\model,1,p\anim_speed
EndIf

or, with the animation speed already set:

If KeyDown(30)
animate p\model,1,p\anim_speed
EndIf

I've been having trouble setting up animations for characters in my game, NPC's especially, and I think it would help if I understood this better.


(tu) sinu(Posted 2007) [#2]
You will just keep attempting to play the anim with your method and it will never get past the first frame as you keep instructing it to start over.

try

if not animseq(entity) = animhandle
animate entity,1,speed,animhandle
endif

this way it will only play the anim if it isn't already playing


killertomato(Posted 2007) [#3]
Hmm, cool. Thanks