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

Just started using Construct 2? Post your questions here

Post » Tue Mar 17, 2015 5:42 am

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.
You do not have the required permissions to view the files attached to this post.
B
7
Posts: 11
Reputation: 299

Post » Tue Mar 17, 2015 8:41 am

Hi,

Image
B
14
S
4
G
2
Posts: 190
Reputation: 3,938

Post » Tue Mar 17, 2015 7:12 pm

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.
B
7
Posts: 11
Reputation: 299

Post » Tue Mar 17, 2015 7:45 pm

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.
B
14
S
4
G
2
Posts: 190
Reputation: 3,938

Post » Wed Mar 18, 2015 12:55 am

That explains my problem. Thank you for your help, and I will use Else in the future to avoid those problems.
B
7
Posts: 11
Reputation: 299


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 4 guests