Checking for two collisions at once on one object

Get help using Construct 2

Post » Tue Feb 10, 2015 7:46 pm

I'm having an issue that I can't quite figure out, so any insight would be greatly appreciated:

I have a fork shaped object with two equal length prongs. The collision mask is shaped in a way that fits over both prongs. When a key is pressed, the fork object moves forward and collides with two separate blocks (one in front of each prong).

My collision event looks roughly like this:

Code: Select all
Fork: On Collision with Block >
Set Block X to Self.X + 50
Set Fork 'returning' to 'True' (which makes the object go backwards)


Originally, I anticipated that the fork would push both blocks in this setup. However, it seems that the fork will only push one of the blocks, as though it's hitting that one "first" and retreating before the event can run for the second block.

How can I make the stick push both blocks at once? Hopefully my example is clear enough to address; I would include a .capx but I'm away from my home computer.

Thanks in advance!
B
5
S
2
Posts: 37
Reputation: 699

Post » Tue Feb 10, 2015 7:47 pm

Add a For each block when checking for collision...
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
15
S
3
G
1
Posts: 329
Reputation: 2,002

Post » Wed Feb 11, 2015 1:59 am

Like this?

Code: Select all
Fork: On Collision with Block
>System: For each Block: Set Block X to Self.X + 50
>[blank]: Set Fork 'returning' to 'True' (which makes the object go backwards)


That doesn't change anything. It still only pushes one block.
B
5
S
2
Posts: 37
Reputation: 699

Post » Wed Feb 11, 2015 6:14 pm

Share a capx so we can take a look at it, then...
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
15
S
3
G
1
Posts: 329
Reputation: 2,002

Post » Wed Feb 11, 2015 7:48 pm

@noisetank

Check the collision box X values on each tine to make sure they are identical (set them to whole numbers). If you have Pixel Rounding set to OFF, and the values are fractionally different, the fork may not collide correctly.

EDIT: This goes for the two boxes as well.

Here's a capx:
https://dl.dropboxusercontent.com/u/12667027/ForkTest.capx
B
31
S
6
G
8
Posts: 232
Reputation: 6,144

Post » Thu Feb 12, 2015 12:09 am

cacotigon wrote:@noisetank

Check the collision box X values on each tine to make sure they are identical (set them to whole numbers). If you have Pixel Rounding set to OFF, and the values are fractionally different, the fork may not collide correctly.

EDIT: This goes for the two boxes as well.

Here's a capx:
https://dl.dropboxusercontent.com/u/12667027/ForkTest.capx


Good advice! This wasn't the solution, but that fact about pixel rounding was new to me and your capx was helpful in showing that the issue is definitely specific to my events.

It turns out that my "returning" boolean was getting switched on too quickly, so the second collision wouldn't occur. Adding a small delay (Wait 0.05 seconds) seems to have fixed that, although it's kind of annoying to see the second block lag after the first. I can probably do some tinkering to try and eliminate that, though.

Thank you for the help!
B
5
S
2
Posts: 37
Reputation: 699


Return to How do I....?

Who is online

Users browsing this forum: Curler, MPPlantOfficial, Yahoo [Bot] and 13 guests