JSPM

  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q66766F
  • License MIT

Utility function for estimating low and high arcs of projectiles. Solves for bullet drop given

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@quenty/trajectory) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    trajectory

    Utility function for estimating low and high arcs of projectiles. Solves for bullet drop given. Returns two possible paths from origin to target where the magnitude of the initial velocity is initialVelocity.

    Installation

    npm install @quenty/trajectory --save

    Usage

    local bullet = Instance.new("Part", workspace)
    bullet.Position = Vector3.new(0, 100, 0)
    
    -- 200 studs down-range
    local target = Vector3.new(200, 100, 0)
    
    -- Use the actual function
    local low, high, fallback = trajectory(bullet.Position, target, 250, workspace.Gravity)
    
    -- Make part follow low trajectory if available, and then high, and then the fallback.
    -- This will ensure the part, assuming it does not hit anything, hits the targetted position
    bullet.Velocity = low or high or fallback

    API

    trajectory(origin, target, initialVelocity, gravityForce)

    Returns two possible paths from origin to target where the magnitude of the initial velocity is initialVelocity

    • origin: Vector3, Origin of the bullet
    • target: Vector3, Target for the bullet
    • initialVelocity: number, Magnitude of the initial velocity
    • gravityForce: number, Force of the gravity

    MinEntranceVelocityUtils API

    MinEntranceVelocityUtils.minimizeEntranceVelocity(origin, target, accel)

    Determines the starting velocity to minimize the velocity at the target for a parabula

    MinEntranceVelocityUtils.computeEntranceVelocity(velocity, origin, target, accel)

    NOTE: This may only works for a minimizeEntranceVelocity

    MinEntranceVelocityUtils.computeEntranceTime(velocity, origin, target, accel)

    NOTE: This may only works for a minimizeEntranceVelocity