Parabola/Tracjectory tracing with Physics / Box2D

  • randomly

    I'm unable to see what's amiss. I don't have access to C2 and what you want to do is different enough it's probably easier to start from scratch.

    In regard to the alternate idea in my last post to calculate the impact point exactly: the process is to use algebra to manipulate the first equation into the form ax^2+bx+c=0 and use the quadratic formula to solve for x. Well except it will be time in the equation. Anyways we can disregard that one for now.

    You said the bullet behavior doesn't give X and y velocty. While this is true, you still can convert it over:

    Vx = speed*cos(angleofmotion)

    Vy = speed*sin(angleofmotion)

    You can also convert it the other way

    Angleofmotion = angle(0,0,vx,vy)

    Speed = distance(0,0,vx,vy)

    The most complicated bit of the original example are these three actions:

    add vx*dt to X

    Add gravity*dt to vy

    Add vy*dt to y

    Those change the velocity and position to what they would be after dt seconds. You can replace dt with any duration you like. Next put those actions under a repeat condition and it is done multiple times. So say you repeat 10 times and use 0.1 instead of dt, it'll calculate where the position will be after 10*0.1 or 1second.

    I did skip a step though. Before the repeat you need to set X,y,vx and vy to what the bullet is currently. As a sub-event of the repeat event you can check so see if y is below the ground level, and then stop the loop and place the marker.

    Alternatively you could position a second Sprite at the bullet and move that instead of using Xy variables.

  • R0J0hound

    Thanks so much for answer!

    This works perfectly for predicting the impact while flying!

    The thing is, I want to predict the impact before launching. That means, since the initial speed and gravity are known, I could predict the impact x coordinate, right?

    I just need the right formula for that...

    As I said, your formula works perfectly for predicting the impact when the bullet is flying.

    I don't think though, that I can predict the impact point before the actual launch.

    The reason might be that the angle of motion can't be predicted in the formula for the process of flying.

    Maybe I'm really not grasping something here, or my idea isn't even possible.

    Thanks for your continuous dedication for my problem, I hope I'm clear enough about what my goal is here.

  • randomly Predicting maximum height & range for a bullet.

    https://www.dropbox.com/s/7zhhr5viujvt8 ... .capx?dl=0

    Ground is drag & drop

    Right mouse = shoot

    Mouse wheel = angle

  • 99Instances2Go

    You are amazing, thank you so much!

    I applied your formula(e) to my project and it worked perfectly!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey R0J0hound , thank you for the examples. I'm using this one in my basket game:

    https://www.dropbox.com/s/9tftyryvn0pab ... .capx?dl=0

    Do you have any example that shows where the ball will go after it bounces from a wall?

  • bilgekaan

    It's hard to predict how an object will bounce with the physics behavior without replicating all it's internal bounce code.

    I've done it before with another physics lib. The idea is i let the simulation run ahead for x amount of frames and then rewind.

  • bilgekaan

    It's hard to predict how an object will bounce with the physics behavior without replicating all it's internal bounce code.

    I've done it before with another physics lib. The idea is i let the simulation run ahead for x amount of frames and then rewind.

    Thank you! Somewhat I managed to do it with these events. But I don't think it would work for every situation. For example, my wall's angle is always 0.

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