# How do I simulate the arc of a bullet?

Get help using Construct 2

### » 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)

or in this thread Archer Devlog
B
46
S
21
G
19
Posts: 1,123
Reputation: 14,603

### » 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: 280
Reputation: 2,522

### » 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.
or in this thread Archer Devlog
B
46
S
21
G
19
Posts: 1,123
Reputation: 14,603

### » 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.
or in this thread Archer Devlog
B
46
S
21
G
19
Posts: 1,123
Reputation: 14,603

### » 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.

So now comes the REAL question. How do i write this formula in construct?
or in this thread Archer Devlog
B
46
S
21
G
19
Posts: 1,123
Reputation: 14,603

### » 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

### » 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
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

### » 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.
or in this thread Archer Devlog
B
46
S
21
G
19
Posts: 1,123
Reputation: 14,603

### » 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.
Learning Unity, but C2 still rocks.
B
78
S
20
G
93
Posts: 2,407
Reputation: 56,401

### Who is online

Users browsing this forum: No registered users and 15 guests