Hi, obviously, i’m making a game. i want to ask. How to have different actions when the same button is pressed. For example, I’m making a battle system for my game. How could I press the space bar to trigger my “attack_001” and if I press space bar AGAIN it would trigger “attack_002”, so on and so forth. and when I didn’t press space bar for 5 seconds, it would go back to pressing “attack_001”. You know. Like any other combo system. Please help! Or when you view this ATLEAST suggest something?? really need help.
Hi, I am new to blender and BGE my self… but as a web developer and knowing code i would guess the best way to go about doing this will be to maybe add a script on the action that would “store” the amount of times you pressed space bar… and calculate or randomize the action when it gets to a certain number… I dont know the scripting language used here… will learn it eventual.
But my gues will be something like this.
attack functions you will have might be
attack1 attack2 and attack3… each of them playing the attack animation.
when you hit space bar it stores the value 1.
so you will have a case statement that will then read the input and play option 1 when you hit space again the value is 2, playing the second animation.
in general i would say a script… (i might be wrong… as i said, still new here as well)
this would be something i would like to know as well actually.
Marchosius is right - it would be advisable to do this with Python, but it’s possible in logic bricks. Basically, pressing space will switch the state of the character to one where he plays the attacking animation once, and there’s a delay sensor to switch back to the original state. If you press space before this state expires, then it switches to the next one.
In Python it’s just a simple case of if statement usage and resetting variables when you press the space key.
Okay okay. So anyone have an example blend? It’s really hard to follow Marchosius. And SolarLune, you’re like everywhere! :)) Can’t understand the state logic bricks. I would really prefer logic bricks over python.
Okay, here’s a basic example. There’s no animation - just look at the combo counter at the left (Show Debug Properties is on). Press space when combo is 0 to set it to 1, do it again to set it to 2, etc. If you don’t press space for 1 second, it will reset to 0. In a real game, you would probably have a slight delay between the beginning of the combo portion and the next point where you can press space to advance the combo to allow for each attack stage animation to complete.
LogicComboTest.blend (351 KB)