How do I predecit physics trajectory?

1 favourites
  • 4 posts
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • Hello,

    I have an object, when I click a button, the game applies impulse force J to it.

    I want to predict how it will move (assuming no obstacles, and 0 friction) over time. Ideally a formula like this:

    x(t) = ...

    y(t) = ...

    Currently I found an iterative approach:

    (dtt=0.1, vx0=400, vy0==-500)

    The problem is calculating ay (acceleration in y direction). I couldn't find a formula for it, but I used a hack by calculating the ay of the Ball object (which is moved by the engine), then plugging that value in ay (the value was 500), the method worked, and the created Mark objects resembled the true trajectory of Ball.

    Notice that I set vx0 and vy0 manually instead of using forces and impulses; because I couldn't figure out how the forces work, so I simply applied the ipmulse to the Ball then got those values from the debugger and used them as vx0,vy0!

    The questions are:

    1- Is there a better way?

    2- How to calculate ay given the initial velocities vx,vy? (i.e. before the ball moves)

    3- Any idea how the x(t) and y(t) equations will look like?

    4- Is it possible to use the impulse J, calculate the resultant force F, then calculate vx,vy of that force?

    Thank you!

    Tagged:

  • Hello,

    I have an object, when I click a button, the game applies impulse force J to it.

    I want to predict how it will move (assuming no obstacles, and 0 friction) over time. Ideally a formula like this:

    x(t) = ...

    y(t) = ...

    Currently I found an iterative approach:

    (dtt=0.1, vx0=400, vy0==-500)

    The problem is calculating ay (acceleration in y direction). I couldn't find a formula for it, but I used a hack by calculating the ay of the Ball object (which is moved by the engine), then plugging that value in ay (the value was 500), the method worked, and the created Mark objects resembled the true trajectory of Ball.

    Notice that I set vx0 and vy0 manually instead of using forces and impulses; because I couldn't figure out how the forces work, so I simply applied the ipmulse to the Ball then got those values from the debugger and used them as vx0,vy0!

    The questions are:

    1- Is there a better way?

    2- How to calculate ay given the initial velocities vx,vy? (i.e. before the ball moves)

    3- Any idea how the x(t) and y(t) equations will look like?

    4- Is it possible to use the impulse J, calculate the resultant force F, then calculate vx,vy of that force?

    Thank you!

    Hello, a solution would be to duplicate the object with the same variables and generate the conditions and at the end obtain the final values ​​and carry out the calculation with those values, since they would be the ones that would be obtained when executing the action

  • This question comes up a lot.

    For plotting the path and dealing with the wonky units the physics behavior uses.

    construct.net/en/forum/construct-3/how-do-i-8/create-physics-trajectory-178459

    And similarly to pick an initial velocity so that the projectile hits a certain location.

    construct.net/en/forum/construct-3/how-do-i-8/solved-physics-object-impulse-179677

    1. You basically got the gist of it.

    The physics behavior by default has a fixed timestep of 1/60. But it shouldn’t matter if you update vy like so.

    Vy = vy+ay/2*dt

    Y = y+vy*dt

    Vy = vy+ay/2*dt

    As you found for a physics behavior gravity of 10 the actual vertical acceleration will be x50 times bigger or 500. 50 comes up a lot in the units of the physics behavior.

    2. The second link covers a way to calculate initial velocities.

    3. X(t)=x0+vx*t

    Y(t)=y0+vy*t+0.5*ay*t*t

    4. Impulse isn’t a force. Basically J=mass*velocity so it’s used to change the velocity in an instant. It’s cleaner to just set the velocity than calculate the impulse. But if you really want to calculate an impulse that changes the velocity you can do this:

    Jx = vx*mass/50/50

    Same for jy

    The mass expression provided by the behavior just gives the density is not correct. The correct formula is:

    Mass = area*density/50

    But maybe there’s some conversion you can do.

    Beyond that you can account for linear damping too, and there may be other subtleties.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This question comes up a lot.

    For plotting the path and dealing with the wonky units the physics behavior uses.

    https://www.construct.net/en/forum/construct-3/how-do-i-8/create-physics-trajectory-178459#forumPost1095848

    And similarly to pick an initial velocity so that the projectile hits a certain location.

    https://www.construct.net/en/forum/construct-3/how-do-i-8/solved-physics-object-impulse-179677?kws=Projectile

    1. You basically got the gist of it.

    The physics behavior by default has a fixed timestep of 1/60. But it shouldn’t matter if you update vy like so.

    Vy = vy+ay/2*dt

    Y = y+vy*dt

    Vy = vy+ay/2*dt

    Thank you very much :)

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