Is there a way to store commands entered to be performed in that order?

For example if I jump and I hit the crouch button - I want him to crouch as soon as he lands OR

If like in Dark Souls - when you press the attack button before you finish your 1st attack animation - he will attack with a 2nd combo move

Either blueprint or C++

I don’t think there’s a direct way to store key presses up for later. If there is, I’d be glad to learn about it. :slight_smile:

There a couple of ways to work around that, though.

The first idea that jumps to mind is to “convert” a key press into something more easible storable (like an enum value) and push it into an array of “queued” commands if a command cannot be executed right away. Then when the current action ends, you could get and remove the first element of the array (if it’s non-empty) and, depending on its value (for example using a Switch node), trigger the function the command would have triggered if it had been possible at the time.

If you only have a few highly specific situations where a given action might not be possible at the time but needs to happen later, you could also use Gate nodes. In response to the key press, add a Branch. If the action is possible right now, do that. Otherwise if the action will be possible later, open a Gate. When the current action preventing the execution of the command ends, attempt to enter the Gate. This will only execute if the player had pressed the other key earlier. After triggering the action, make sure to close the gate again. You can also close the Gate if the player does something else in the meantime invalidating the second key press.

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/FlowControl/index.html#gate

For combo moves, you could also check out Animation Montages. Use Branch Points to handle switching between different animations and Anim Notifies to trigger specific effects depending on which animation is playing (like different amount of damage dealt, stunning the target or knocking the opponent a specified distance).

These are just some ideas off the top of my head. Which one works best really depends on the circumstances of your game. You might end up using a combination of all three or come up with something entirely different.

Good luck!

Hey :slight_smile: Thanks for the quick reply, I will give this a try - I’m still trying to wrap my head around enums and how they work - pretty good idea

The best part of gameplay engineering, is the how!

So, don’t make things complex, that takes time and probably going to reproduce more bugs.

If I were you, I would do save game into a *.sav file for any input sequence. At your case for example, with any key pressed, i’ll:

  1. Check if the character on ground or on air.
  2. If on ground, then I’ll process the action.
  3. If on air, I’ll save to file (lets say the jump is0, the crouch is1, the punch is3), then you save a sequence of numbers as string.
  4. Once the player on ground, I load the string using LoadFromSLot
  5. Finally apply actions sequence based on the string and using if/else if.

-m

This is how I have it set up currently -

When I press jump button - he jumps - turns on the bool Character is in air - When landed that bool is turned off
When Pressing crouch - “if character is in the air” - if it’s not in the air - then I can crouch…

The problem is that If I do press the crouch button while the character is in the air - and hold it down…when he lands…he doesn’t crouch…because at the time of the button press - the bool was that he was in the air

  • And when he does jump - my character put’s his legs in the air and since it’s not root motion - the root capsule lands 1st and then his legs come down…- but that’s a whole other problem I’m trying to solve

This is how I have it set up currently -

When I press jump button - he jumps - turns on the bool Character is in air - When landed that bool is turned off
When Pressing crouch - “if character is in the air” - if it’s not in the air - then I can crouch…

The problem is that If I do press the crouch button while the character is in the air - and hold it down…when he lands…he doesn’t crouch…because at the time of the button press - the bool was that he was in the air

  • And when he does jump - my character put’s his legs in the air and since it’s not root motion - the root capsule lands 1st and then his legs come down…- but that’s a whole other problem I’m trying to solve