Physics: objects blasting through each other

Get help using Construct 2

Post » Fri Jan 11, 2013 7:12 pm

Here is what I am facing. I have a family of objects named "Discs". I want the discs to all have physics and collide and bounce off each other, except when a red disc and a blue disc collide. Then I want the one that is spinning faster to destroy the other one and continue through.

Like this:


Is there a way to detect a collision and prevent the resulting rebound?
Visit me at EgoAnt.com
B
50
S
7
G
7
Posts: 75
Reputation: 6,353

Post » Mon Jan 14, 2013 1:18 pm

I had a similar problem with a tank game, if you ran over the bullets, they would get stuck in your wheels. :D

You can selectively turn off collisions between certain physics objects, but they'd need to be different sprites.

So if your blue disc is turning into a red disc, you'd need to swap them out and get the newly spawned red disc to inherit the velocity / rotation of the blue disc.

Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Mon Jan 14, 2013 7:08 pm

I eventually decided that the work I was putting into this wasn't really worth it. I kept the bullets deflecting as they were and it's still pretty fun. It actually created a new strategy in the game where you could set up some stationary discs to defend your base.
Visit me at EgoAnt.com
B
50
S
7
G
7
Posts: 75
Reputation: 6,353

Post » Mon Jan 14, 2013 7:26 pm

If you destroy one sprite on collision doesn't the other sprite carry on uninterrupted?
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Mon Jan 14, 2013 9:06 pm

Oddly enough, no. The order of actions seems to be:

1. Physics detects collision
2. Physics are applied
3. Collision event is raised in Construct
Visit me at EgoAnt.com
B
50
S
7
G
7
Posts: 75
Reputation: 6,353

Post » Mon Jan 14, 2013 9:13 pm

Use colliding at offset, using the physics objects movement vector as the offset and test for collision before they collide, as it were. :)

That way you can turn off collision on the one you want destroyed.
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Mon Jan 14, 2013 9:23 pm

physicsDestroy.capx (r115) In this simple example the 'destroyer' sprite never bounces off the sprites it hits for me. But maybe it depends on speed or framerate.
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Mon Jan 14, 2013 9:30 pm

Maybe it is something that is fixed in the Beta release. I am running the official release path right now (so I can't open your file)
Visit me at EgoAnt.com
B
50
S
7
G
7
Posts: 75
Reputation: 6,353


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, jeffige, LeFuji, plinkie, Radulepy and 1 guest