How do I simulate the arc of a bullet?

Get help using Construct 2

Post » Fri Jun 19, 2015 10:46 am

I want to calculate a smooth curve for a sprite following my hidden bulle to simulate gravity in an isometric view.

I can manage make a linear decline based on the distance travelled, but i want a smooth curve similar to what I'm trying to illustrate in this image. Is it possible with math/expressions to get that kind of decline? and what expressions calculations should I use?

What I'm trying to achieve is to adjust the Y position (distance between the bullet and the sprite) following the bullet in a more curved fashion, rather than a linear decline (showed in red)

Image
Follow my progress on Twitter
or in this thread Archer Devlog
B
38
S
15
G
17
Posts: 949
Reputation: 12,320

Post » Fri Jun 19, 2015 11:20 am

Have you tried to use the Physics behavior?

I'm not quite sure because I never used it, but I think it might be just what you need
B
17
S
7
Posts: 277
Reputation: 2,514

Post » Fri Jun 19, 2015 11:23 am

To clarify.

Each bullet has 2 instance variables which i use to calulate the decline.
"bullet.traveldistance" = how many pixels the bullet will travel before it's destroyed.
"bullet.offset" = They Y offset of of the sprite following the bullet, based on the distances between the player and the traveldistance instance variable.

When the bullet is created the offset is '-40' ... when the bullet reaches the endpoint the offset value is '0'

So somewhere inbetween here i need to do some adjustments to the offset in order to get an arc.
Last edited by tunepunk on Fri Jun 19, 2015 11:29 am, edited 2 times in total.
Follow my progress on Twitter
or in this thread Archer Devlog
B
38
S
15
G
17
Posts: 949
Reputation: 12,320

Post » Fri Jun 19, 2015 11:26 am

RayKi wrote:Have you tried to use the Physics behavior?

I'm not quite sure because I never used it, but I think it might be just what you need


I've tried it but it doesn't really work in this case. I'm basically just looking for a way to calculate an arc.
Follow my progress on Twitter
or in this thread Archer Devlog
B
38
S
15
G
17
Posts: 949
Reputation: 12,320

Post » Fri Jun 19, 2015 12:02 pm

I googled a bit but I'm not a math genius but i think I have to add another value.. to add (Sagitta) af an arch to the 'offset' value.

Image

So now comes the REAL question. How do i write this formula in construct?
Follow my progress on Twitter
or in this thread Archer Devlog
B
38
S
15
G
17
Posts: 949
Reputation: 12,320

Post » Fri Jun 19, 2015 2:43 pm

s = ut + at^2/2 in 2 axes.

I note this is isometric. I would be inclined to calculate it in real world coordinates and then convert to isometric ones.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Fri Jun 19, 2015 3:15 pm

You might want to look at the Sine behavior.

Here's how I'd do it. Cheap and easy ! ;)
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Sat Jun 20, 2015 10:54 am

Magistross wrote:You might want to look at the Sine behavior.

Here's how I'd do it. Cheap and easy ! ;)


nice example. thanks! Thats not a bad solution!

I managed to make it using the sin expression instead.
Image
Follow my progress on Twitter
or in this thread Archer Devlog
B
38
S
15
G
17
Posts: 949
Reputation: 12,320

Post » Sat Jun 20, 2015 12:59 pm

I made this example a while ago - it's simple and produces a reasonable effect if you know where you want your bullet (arrow in this example) to land - in 2d or isometric. :)
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,214
Reputation: 43,850


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, Bootfit, jorgmaquoi, OddConfection, Rable, unicornspitfire and 10 guests