Just thought Id check here to see if any one had the formula to project where a turning bullet will wind up, after a given time, speed, rate of turn, and angle.

No cap needed, but wont be turned down of course.

Thanks

8 posts
• Page **1** of **1**

This is not the answer, (consider it a bump) but on a quick search I found this Parabola calculator showing kicking a ball that may be good at math, but a bit of a fail on ball kick.

Click "kick it" and see how math simulates life. "Except for how the air affects it."

It made me laugh out loud.

http://www.mathsisfun.com/geometry/parabola.htmlParadox 2013-12-03 17:40:19

Click "kick it" and see how math simulates life. "Except for how the air affects it."

It made me laugh out loud.

http://www.mathsisfun.com/geometry/parabola.html

**Posts:**903**Reputation:**40,756

B

242
S

63
G

33
per tick the movement will be:

x: cos(startangle+turnrate*elapsed_time)*bulletspeed*dt

y: sin(startangle+turnrate*elapsed_time)*bulletspeed*dt

turnrate = turnrate per time

Since dt is not constant, you can't solve the integral up front. Nonetheless you can approximate it, if you can assume your game to run at a stable fps, because then you can basically see this function as

cos(A+B*x)*C where the integral would be sin(A+B*x)*C/B

x is your time

C = the constant dt you expect (60 fps -> 1/60) multiplied by the bullet speed

A = starting angle

B = angle turned per second

the result would be the x-position in relation to the starting point of your bullet

Maybe it is possible to eliminate the dt by adjusting the turnrates dynamically along the process, so that the function will look like this:

cos(startangle+turnrate*dt*60*elapsed_time)*bulletspeed*dt

I am not sure how the turn angle expression should look for that, though, maybe a simple

every tick: set angle to angle+turnrate*dt will do the trick.

edit2: yeah I guess this will suffice and makes the end point not reliant on fps:

http://s000.tinyupload.com/index.php?file_id=34186910167149130523mindfaQ 2013-12-03 20:25:41

x: cos(startangle+turnrate*elapsed_time)*bulletspeed*dt

y: sin(startangle+turnrate*elapsed_time)*bulletspeed*dt

turnrate = turnrate per time

Since dt is not constant, you can't solve the integral up front. Nonetheless you can approximate it, if you can assume your game to run at a stable fps, because then you can basically see this function as

cos(A+B*x)*C where the integral would be sin(A+B*x)*C/B

x is your time

C = the constant dt you expect (60 fps -> 1/60) multiplied by the bullet speed

A = starting angle

B = angle turned per second

the result would be the x-position in relation to the starting point of your bullet

Maybe it is possible to eliminate the dt by adjusting the turnrates dynamically along the process, so that the function will look like this:

cos(startangle+turnrate*dt*60*elapsed_time)*bulletspeed*dt

I am not sure how the turn angle expression should look for that, though, maybe a simple

every tick: set angle to angle+turnrate*dt will do the trick.

edit2: yeah I guess this will suffice and makes the end point not reliant on fps:

http://s000.tinyupload.com/index.php?file_id=34186910167149130523

Visual Novel 'Engine' in 100 Events

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

**Posts:**788**Reputation:**3,788

B

22
S

9
G

1
Hi, here's my 2c.

Since the motion is just along a circle we can calculate the center and radius of that circle and build a nice exact formula to find where the object will be. You do have to account for the case where the rate of turning 0, because motion will be in a straight line and my formula will fail.

Here's a capx:

[https://dl.dropboxusercontent.com/u/5426011/examples20/position_perdict.capx[/url]

The last 3 events are the formulas. The rest is just gui nonsense.

Since the motion is just along a circle we can calculate the center and radius of that circle and build a nice exact formula to find where the object will be. You do have to account for the case where the rate of turning 0, because motion will be in a straight line and my formula will fail.

Here's a capx:

[https://dl.dropboxusercontent.com/u/5426011/examples20/position_perdict.capx[/url]

The last 3 events are the formulas. The rest is just gui nonsense.

**Posts:**5,393**Reputation:**75,847

B

94
S

33
G

118
You'll need the integral once you change the amplitude, turnrate or speed over time, though.

Visual Novel 'Engine' in 100 Events

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review

**Posts:**788**Reputation:**3,788

B

22
S

9
G

1
8 posts
• Page **1** of **1**

## Who is online |

Users browsing this forum: dop2000, LunaticCat, plinkie and 6 guests |