Physic based explosion - help

For questions about using Classic.

Post » Mon Aug 23, 2010 10:13 pm

Hi guys,
I'm working on small prototype now but can't figure out one thing. I want to have physic based environment and I want to throw grenade at it... My question is, how to make an explosion in physics based game so the environment near explosion is affected in appropriate way.
Thanks a lot.
B
4
S
1
G
3
Posts: 85
Reputation: 1,234

Post » Mon Aug 23, 2010 10:43 pm

you could have a small Area of Effect sprite, stretch it to size dynamically and for all objects colliding it, apply a force proportionate to the distance to the center.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Tue Aug 24, 2010 11:38 am

Hmm. I haven't tried this specific scenario, but I did make a kind of physics based explosion by spawning multiple instances of a physics enabled object, and adding force via events to each one.

Possibly, you could use an explosion sprite that grows outward, and use collision events to add force, although this is just musing and I haven't tried anything remotely like it.

Another thing with physics objects is that they don't like overlapping at all. They tend to fly out violently when stuck on top of each other.

Always: physics object overlaps explosion sprite
Set physics object x to explosion sprite x
Set physics object y to explosion sprite y

If more than one overlaps, the physics engine will fling them outwards unpredictably. I don't know if this is any use - but perhaps it will inspire more ideas.
B
2
G
2
Posts: 42
Reputation: 734

Post » Wed Aug 25, 2010 7:57 am

Silly me, a distance threshold is much less wastefull than a collision check.

Just pick by distance < something and then apply force accordingly
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Aug 25, 2010 8:33 am

it doesn't like them overlapping because it's supposed to be simulating an approximation of real world physics, where things aren't supposed to overlap :wink:

you can use the 'disable collisions with object' action on each one as it's spawned to prevent this though
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Wed Aug 25, 2010 1:49 pm

That makes sense. If you use "get angle between point A and Point B" (and then rotate the result 180 so that it's the opposite direction) and then apply force, you should have a radial push outwards.
B
2
G
2
Posts: 42
Reputation: 734


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests