Question about punching

Blitz3D Forums/Blitz3D Programming/Question about punching

D_Town_Tony(Posted 2003) [#1]
I can't seem to get my code to work for a series of punches.
What I want to happen is if you press the key you punch, and if you push it again you follow the basic punch with an additional punch. The way I am doing it right now is by having a counter keep track of what punch I am doing, and using a single animation to store all the punches. If you keep hiting the punch key it'll keep running throw the punches, but if you stop and a certain punch ends it stops the animation. why won't my code work?

If Char_1_Punching=0 And KeyHit(40) Animate Char_1,1,1.25,7,5 Char_1_Punching=1
If Char_1_Punching=1 And AnimSeq(Char_1)=7 And AnimTime(Char_1)>5 Char_1_Punching=0
If Char_1_Punching=1 And KeyHit(40) And AnimSeq(Char_1)=7 Char_1_Punching=2
If Char_1_Punching=2 And AnimSeq(Char_1)=7 And AnimTime(Char_1)>10 Char_1_Punching=0
If Char_1_Punching=2 And KeyHit(40) And AnimSeq(Char_1)=7 Char_1_Punching=3
If Char_1_Punching=3 And AnimSeq(Char_1)=7 And AnimTime(Char_1)>15 Char_1_Punching=0


Ricky Smith(Posted 2003) [#2]
What I would do would be to have a basic Fight Idle animation running continually when no other action is triggered.
I would then check to see if KeyHit(40) occured.
If the Punch button has been hit first of all check to see if we are already in the punching sequence and if so are we at a frame where we can throw another punch. If yes then do the Punch Sequence.
If we are in the Fight Idle sequence then just trigger the Punch Sequence.
As the Punch Animation sequences are 'one-shot' we can check when the animation has stopped and return to the Fight Idle sequence.



IF KeyHit(40) AND AnimSeq(Char_1)=7 And AnimTime(Char_1)> A_frame_where_its_ok_to_rerun_the_sequence THEN
    Animate Char_1,3,1.25,7,5 'one-shot punch sequence
END IF
IF KeyHit(40) AND AnimSeq(Char_1)= fight_idle THEN
       Animate Char_1,3,1.25,7,5 'one-shot punch sequence 
END IF

IF NOT Animating(Char_1) THEN   Animate Char_1,1,1.25,fight_idle,5  'looping fight_idle sequence

This will ensure that when the punch sequence finishes the model will return to the fight idle sequence ready for another punch.

For simplicity you could leave out the first check and only trigger the punch sequence when the model is in Fight Idle mode - this does mean though that you couldn't trigger another punch until the previous was fully completed. Depending on how you have created your animations this may not be a problem.


Litobyte(Posted 2003) [#3]
To make it really good, custom as you like, you should think to write a custom animation system.

With that, animate command will become useless.
You will use SetAnimTime entity,time#[,anim_seq] to play your animations, but beware: you won't have sequences interpolation in this way!

The best of all (system I used for Dragan's Quest), would be mix the 2 methods, and so use animate for certain sequences, and SetAnimTime entity,time#[,anim_seq] for other kind of stuff, like keypress-punching or kicking.

hope that help