Bullet end point

0 favourites
  • 7 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • 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

  • 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.html

  • 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:

    s000.tinyupload.com/index.php

  • 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

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

  • R0J0hound is considered as math genius. :)

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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Alright I think I can figure something out now.

    I think what I'll try is a drag and drop kind of thing where the end point will be a point on a circle, and the center is the bullet origin.

    Thanks guys!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)