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.