How do I make an object travel making a parable.

Get help using Construct 2

Post » Thu Mar 26, 2015 5:53 am

I'm using turret behavior, when On shoot triggers, I'm spawning a bullet.

How do I make this object with bullet behavior travel making a parable instead of going straight to the target?? Like an arrow.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Thu Mar 26, 2015 7:09 am

If you use the Set Angle it should do the trick.
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Thu Mar 26, 2015 6:16 pm

use set Angle and try to add physic behavior to your projectile
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
63
S
14
G
2
Posts: 291
Reputation: 6,641

Post » Thu Mar 26, 2015 9:19 pm

@emoaeden
Set angle have nothing to do with it, buddy. :/ It just don't do what I want. I need to go from a to b in a parable instead of a straight line.

@puntodamar
Physics behavior for this is a waste for memory and cpu. Totally innefficient and not necessary :/
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Thu Mar 26, 2015 10:02 pm

The bullet behaviour already has gravity - just use that to make the bullet describe a parabolic arc. It's as simple as that for a side view game; if your game is isometric then the maths will be more involved and you'll have to vary bullet speed and apparent gravity according to shoot angle / player heading.

Edit to add: If you want to calculate the shot angle so the bullet describes a parabola and then hits the intended target, you'll need to solve the equations of motion for x and y velocities - x velocity constant, y velocity accelerated by gravity and overall distance traveled the delta y from turret to target.

For x: s = ut

For y: s = ut + 0.5at^2

Time traveled for both is the same... I'm using my phone now but if this is what your after I'll try and put together an example later.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,207
Reputation: 43,836

Post » Thu Mar 26, 2015 10:50 pm

@Colludium

It's not a platform game. It's a tower defense like kingdom rush. The example of what I need is right here (https://youtu.be/WbS_n-vCIek?t=1m41s)
... And I'm retarded regarding to math. Especially when it's about movement calculation :/
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Mar 27, 2015 12:01 am

Here you go... Click to mark a target position and the arrows will fly to hit each one precisely. I enjoyed putting this together :) .



URL deleted. See later post on page 2 for update.
Last edited by Colludium on Thu Nov 12, 2015 5:11 pm, edited 1 time in total.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,207
Reputation: 43,836

Post » Fri Mar 27, 2015 2:12 am

Colludium wrote:Here you go... Click to mark a target position and the arrows will fly to hit each one precisely. I enjoyed putting this together :) .



simple parabolic arrow capx


That's reaaaallly cool man. Thank you very much. Could you explain a little bit the math you did? I'm just terrible doing math.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Fri Mar 27, 2015 2:37 am

Sure. I used one equation of motion (variables: u is starting velocity, s is displacement, a is acceleration and t is time taken):

s = ut + 0.5 at^2

By setting the arrow time of flight to a constant and known value, it becomes easy to figure out the missing variables. This does not necessarily reflect reality, but it's more than good enough for a game. For movement in the x direction, I chose to make the movement linear in all screen directions ie constant x velocity and zero acceleration. Thus the equation becomes u = s / t.

For movement in the y direction (ie vertical) I had to consider gravity acceleration. The variable s is the difference between start and end y values. Starting velocity is then figured by manipulating the equation to give u = (s - 0.5 at^2 ) / t. All of the variables s, a and t are known, so the starting vertical velocity can be figured out. That leaves moving the arrows, which is done every tick by giving each arrow object an object variable Y_Vel (for y velocity)... et voila!
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,207
Reputation: 43,836

Post » Fri Mar 27, 2015 2:59 am

@colludium
It's a bit more clear ^^. Thanks!
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Next

Return to How do I....?

Who is online

Users browsing this forum: Fradno and 14 guests