Skip to content

.solveMoving() Playcanvas

Alex edited this page Aug 20, 2020 · 1 revision

Ballistics.solveMoving(from, target, speed, velocity, [gravity])

  • from (pc.Vec3) position from which the projectile is fired
  • target (pc.Vec3) position of the target that projectile is trying to hit
  • speed (number) projectile speed
  • velocity (pc.Vec3) velocity of target
  • gravity (number, optional) the current world gravity, defaults to project global settings
  • Returns 1 - 4 firing sulutions, if found, otherwise null
{
    lowAngle: pc.Vec3(),
    highAngle: pc.Vec3(),
    s3: pc.Vec3(),
    s4: pc.Vec3()
}

Solve firing angles for a ballistic projectile with speed and gravity to hit a target moving with constant, linear velocity.