How do I use sprite collisions to cause a direction change?

  • The excellent How To Make A Platform Game tutorial taught me how to use invisible sprites at the edge of platforms to cause enemy sprites to reverse direction rather than falling off. While trying to implement it in my own game I found that my enemies would respond to the sprite on one edge but ignore the other.

    I've attached a simplified example of what I mean. In Example.capx, the yellow sprite should bounce between the two red sprites but it only acknowledges the first one. I would appreciate another pair of eyes looking at the event to point out where I am going wrong.

  • Hi,

  • Thank you, beufreecasse, that worked like a charm! Perhaps if it isn't too much trouble you could explain to me the reason that your method works and mine didn't? I don't quite grasp why as the conditions seemed to be being met.

  • If you log the two "on collision with sprite2" triggers you will see that for the second block the Sprite is set to mirrored and not mirrored at the same time.

    This is because the events are read from the top to the bottom, if you change the mirrored state to not mirrored and after do another check on not mirrored state this second condition will be also true.

    So don't forget using same trigger and "else" on your conditions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That explains my problem. Thank you for your help, and I will use Else in the future to avoid those problems.

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