Top-down physics - can I simulate a shockwave?

Get help using Construct 2

Post » Fri Mar 08, 2013 10:22 pm

Hi there,

Still quite new to Construct 2 but having a great time with it. At the moment I'm working on a top-down, twin-stick shooter (a l Smash TV of old).

I'd like to add an element where the player can press a button to release a 'shockwave' from his suit, pushing enemies back - so a rapidly expanding circle with a defined radius that has a knockback effect on anything it hits. Is this possible and how would I go about it? I've read the tutorials and I've been playing about with the physics functions a bit but I'm still not really sure where to begin!
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Fri Mar 08, 2013 10:26 pm

At this point , physics behavior only work with platformer ... You might need to code all of this on your own ...
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Fri Mar 08, 2013 10:48 pm

Very likely you would expand a circle outward from the center of the player (maybe using Sprite.setScale()?), and check for collisions at each step. If a collision occurs, you would move the enemy(or whatever) object at an angle (found by taking the system.angle(x1,y1,x2,y2).
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Fri Mar 08, 2013 10:58 pm

you can use physics in top down. Just set the world gravity to 0 and move all the sprites via normal movement functions.

Have a circle sprite that expands (scale) and then it collides with the enemy, Apply Impulse at Angle. See cincipon's formulas.

It's do able.

You will have to wrestle with things colliding on their own though.
B
30
S
10
G
7
Posts: 416
Reputation: 7,239

Post » Fri Mar 08, 2013 11:35 pm

[QUOTE=cincipon] Very likely you would expand a circle outward from the center of the player (maybe using Sprite.setScale()?), and check for collisions at each step. If a collision occurs, you would move the enemy(or whatever) object at an angle (found by taking the system.angle(x1,y1,x2,y2).[/QUOTE]

Cheers - I'm with you up until you said "taking the system.angle(x1,y1,x2,y2)" - how would that work and what action would I use? If I'm applying an impulse, how do I tell it which direction to push them in? (So enemies above the player are pushed up, ones to the right are pushed right etc)
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Sat Mar 09, 2013 12:08 am

The action is "Apply Impulse at Angle" and the Parameter is the formula to find out the angle between the player and the object to apply impulse to.

So whenever you select an action (almost any action) there is a window with a textbox that you can type into to input X and Y or whatever you are inputting. Above (I think) that is a greyed out textbox that appears, and becomes opaque when you hover over it (@Ashley I think this is a bad UX decision). Once you've found that, you can pcik the System object, then scroll down and pick the angle expression, and it will help you along.

Once you get more used to this sort of thing it will become MUCH friendlier to say sytem.angle(x,x,y,y) or object.Platform.VectorY than it will be to say click this choose that do this. =) Good luck!

Play around with it, if you fail, put together a capx and link to it here and we can look into it.
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Sat Mar 09, 2013 11:27 am

Thanks, I've figured it out now. Works a treat!
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Sat Mar 09, 2013 3:53 pm

Wonderful! I _LOVE_ Smash TV! Good luck.
B
6
S
1
G
1
Posts: 70
Reputation: 702


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest