@quenty/trajectory

2.6.1 • Public • Published

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

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @quenty/trajectory

    Weekly Downloads

    1

    Version

    2.6.1

    License

    MIT

    Unpacked Size

    12 kB

    Total Files

    9

    Last publish

    Collaborators

    • quenty