No announcement yet.

Predicting impact of physics object

  • Filter
  • Time
  • Show
Clear All
new posts

    Predicting impact of physics object

    Anyone do any work where you predict based on current movement of a physics object an approximate path to determine where it'll land. Or where it will be if it maintains that movement.

    Basically looking if possible to create an ai that will attempt to avoid or catch a ball that is flying.
    Inphidel / Brian - Developer of Ultraball

    Don't shy away from bugs in your game. Don't play it as intended. Break your game so you can fix it!

    try this: 1/2*a*t*t


      If gravity is the only force acting on the object, you can determine the object's movement pretty easily through integration.

      Choose a small step time (dt), delta velocity will be g*dt and delta position will be v*dt, v being the new velocity. You can do this until the object intersects the ground.
      Note that if the object is not a ball, you can also integrate rotation (C++ only, as quaternions are not available in Blueprints as far as I know) to better predict the impact point (it won't have that much influence, though).

      Nawrot's suggestion is the analytical solution: for initial position and velocity x0 and v0, you have v(t) = a*t + v0 (here, a = g), and x(t) = 1/2 a*t2 + v0*t + x0.