# How do I Make Parabolic Projectile and Movement

Get help using Construct 2

### » Wed Apr 23, 2014 9:33 pm

Hi guys... i was wondering if you could lend me some of you wisdom in the fiel of mathematics and C2
im looking for a bullet that will travel in a parabolic way (like castlevania's skeletons)... and hit the player, but not ramdom, but with precision (see the picture attached) i can make a parabolic bullet but i cant do it that it will always fall where the players is... so if he does not moves it will hit him.
how do you do it??? 0:

another thing if its possible to implement this to make enemies jump in a parabolic trajectory and fall in the player... that would be awesome...

thanks in advance, any help will be appreciated
You do not have the required permissions to view the files attached to this post.
B
23
S
6
G
3
Posts: 316
Reputation: 3,461

### » Wed Apr 23, 2014 11:29 pm

Graphics looks really nice
The bullet behaviour has gravity. Just try to play around with that I guess.

Check out our start-up and configure your own helmet in true 3D.
B
48
S
14
G
15
Posts: 1,177
Reputation: 12,467

### » Thu Apr 24, 2014 2:43 am

Here is a capx with a few different methods:
/examples22/cannon.capx
https://www.dropbox.com/s/f651hqzv53u23 ... .capx?dl=1

The first method uses a fixed speed and finds an angle. The angle is NaN if there is no solution.
The second uses a fixed angle and finds a speed. The angle is NaN if there is no solution.
The third is like the second but the angle is always pointed above the target so there always is a solution.

Finally the bullet behavior wasn't used since the path isn't accurate when using gravity.
Last edited by R0J0hound on Mon Jul 03, 2017 6:36 pm, edited 1 time in total.
B
101
S
39
G
134
Posts: 5,588
Reputation: 85,514

### » Thu Apr 24, 2014 5:15 am

R0J0hound wrote:Here is a capx with a few different methods:
https://dl.dropboxusercontent.com/u/542 ... annon.capx

The first method uses a fixed speed and finds an angle. The angle is NaN if there is no solution.
The second uses a fixed angle and finds a speed. The angle is NaN if there is no solution.
The third is like the second but the angle is always pointed above the target so there always is a solution.

Finally the bullet behavior wasn't used since the path isn't accurate when using gravity.

i will check it out =) thanks a lot...and report findings
btw your plugins are awesome... and many of my game's features could not be possible wihtout you =) thanks
you surely will appear in my game with other user that are so firendly and helpful XD
B
23
S
6
G
3
Posts: 316
Reputation: 3,461

### » Sun May 18, 2014 7:20 pm

Awesome example, mod speed mode is so close to what i need as the flight time seems to remain the same no matter how far away i click from the cannon. Changing the angle (to Mouse.Y-400 rather than -200, for example) alters the flight time, is there a way i can have fixed flight time regardless of the angle? I'd like to have 3 projectiles that have different angle but same flight time so they all hit the target at the same time.
B
8
S
2
Posts: 18
Reputation: 611

### » Wed May 21, 2014 12:29 pm

is it possible to combine this with Turret behavior ?
B
9
S
2
Posts: 31
Reputation: 635

### » Wed May 21, 2014 3:24 pm

@Alpro
Having a fixed flight time and having a different launch angle isn't physically accurate since it requires each cannonball to have a different gravity.

Do do a launch here are the formulas. "angle" is the launch angle and t is the flight time. You'll need to change event 5 to use ball.gravity instead of gravity in the equations.

ball set vx to (x_target-x_start) /t
ball set vy to ball.vx*tan(angle)
ball set gravity to 2*(y_target-y_start-ball.vy*t)/t^2

@bear13
Probably no, the turret behavior is for straight shots, but with some creativity you possibly could do something similar with events.
B
101
S
39
G
134
Posts: 5,588
Reputation: 85,514

### » Sun May 25, 2014 7:18 pm

Can this be done without using gravity then? Like a formula to follow an arc from point A to point B, with a specific angle and flight time? There has to be a way...
B
8
S
2
Posts: 18
Reputation: 611

### » Mon May 26, 2014 3:49 am

@Alpro
It can be done by modifying the capx with the info from my last post, or you could setup a function to do a Quadratic Bezier Curve, which is like lerp but you can do this:
http://en.wikipedia.org/wiki/B%C3%A9zie ... tic_curves
and here's the math for it:
http://en.wikipedia.org/wiki/B%C3%A9zie ... ier_curves

The math doesn't look much simpler:
https://dl.dropboxusercontent.com/u/542 ... /qarp.capx
You can change up the path by changing xmid and ymid to another location.
B
101
S
39
G
134
Posts: 5,588
Reputation: 85,514

### » Wed May 28, 2014 12:16 pm

Thanks, i will experiment with this.
B
8
S
2
Posts: 18
Reputation: 611

Next