Combos and logic bricks? (SOLVED)

Hello everybody!

I have a problem I’ve been trying to resolve for an hour now, without finding the solution, although it looks quite simple.
I have a character, which got two animations. I would like him to be able to play the first one if a touch is used, and then if the touch is pressed again, play the second animation. So far I used the two solutions I imagined :

  • the first one consist in creating an int property, which is set to 0 at the beginning. This property has to be equal to 0 to play the first animation. If it is equal to 0 and that the right key is pressed, then it plays the animation, and add 1 to the property’s value. To play the second animation, it’s basically the same thing, but the property has to be eqal to 1 and that it add -1 to the int property.
    But that doesn’t work. The property changes if I press the right key, but as soon as I release it, the property comes back to the original value. To solve the problem, I think I should find a way to make this property keeps it’s value even after the key is not pressed. Is there a way to achieve this? Does anybody have an other solution?

  • for the second one, I used a timer property : to play the first animation, the timer value has to be bigger than 2, and if the key is pressed it should play the first animation and make the timer value equal to 0. If the key is pressed and that the timer value is smaller than 2, then it plays the second animation.
    But here again, it doesn’t work. When the key is pressed, the value immediatly swap to 0, and it plays directly the second animation, without playing the first one. I tried to use two different intervals for the first animation, but it doesn’t work well, I should find the very precise values to use (and that would take long), and this kind of solutions are messy and always brings problems.

That doesn’t look very difficult to achieve, though, and there should be a simple and efficient solution. I made researchs, but all I saw were the solutions I mentionned above, with the same problems. Do anyone knows how to solve that?

Thanks for reading.:slight_smile:

Not quite sure what you’re wanting…but I’ll give it a shot. From what I read, I’ll assume you want your character to do this:

  1. when a certain key is pressed (let’s say ‘w’) it plays the first animation
  2. when the same key is pressed again, it plays the second animation

Now, what I don’t quite get is: is there a time between when the user must press ‘w’ to play the second animation (i.e. if ‘w’ is pressed once, the second animation will only play if it is pressed again within a certain time) or does it just toggle between playing the two animations?

If all you’re wanting it to do is toggle between two actions, here is my suggestion:
This will play “Action1” when ‘w’ is first press, “Action2” when it is pressed again, “Action1” when pressed again…and so on.

If you are wanting a time interval (i.e. to do something like a double jump–you have to press the key again in a certain time) this might get you started:

Hope that helps!

DanZMan > Thanks a lot for your detailled answer, you really helped! It works perfectly now!

No problem! Glad it helped.

Wicked :slight_smile: Expressions are the best XD

@John_tgh: Actually, expressions are second best. Python is the best…you can do a whole lot more, with a whole lot less, a whole lot faster. :slight_smile:

@John_tgh: Actually, expressions are second best. Python is the best…you can do a whole lot more, with a whole lot less, a whole lot faster. :slight_smile: