Problem with animation - What's wrong with this logic?

From the Asset Store
Ninja char for your game! Make your own Shinobi game with this art.
  • Hi there!

    Why isn't this working? Nothing happens, the animation doesn't change. I've tried a bunch of different solutions like using variables and sub-events instead but nothing works.

    Thanks in advance,

    Tommy

  • I came up with this solution and it works.

  • you can make a sub-condition to your "green arrow event"

    so you would have -

    ON collision:

    if animation red playing, set animation to green

    if animation green playing, set animation to red

    instead of having two "on collision"

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • eleanorjmorel - First of all, thanks for trying to help me out :) As I wrote in the original post, I've already tried sub-events, using variables and all other possible solutions. Nothing worked until I added a "wait" event. I only had two "on collision" to see if it would help but since it didn't, I went back to using sub-events + wait 0.05 seconds.

  • You need an Else to make it work properly, in your subevent.

    If red ...

    Else if green ...

    Using wait to fix logic is a bad habit you don't want to start.

  • The reason it shift immediately back to red is the way Construct reads the events, on first tick it will check on collision, check if color red, change to green, and next tick, it will do the same, and since the sprite is now green, it turns it back to red, that's why "Else" condition is necessary here as blackhornet said, it basically will check if conditions are true, and if not it will check the "Else" condition instead, all that in a sub-event under your collision trigger;

    And I agree, it's not recommended to use the wait action that way, it can become pretty messy later on especially with animation timing

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)