MW UNITY NAMESPACE








































public static class

Aerodynamics


Computations for Aerodynamics.



public static Vector3

AirResistance (Rigidbody Self)

Summary:

The direction of natural air resistance.

Params:

Self:

        The Rigidbody to apply air resistance to.



public static float

Lift (float LiftCoefficient, float Density, float Velocity, float WingArea)

Summary:

The scale of lift applied to a wing with WingArea travelling at Velocity through a fluid at Density with LiftCoefficient.

Params:

LiftCoefficient:

        The heuristic coefficient for lift.

Density:

        The density of the fluid.

Velocity:

        The speed at which the wing is travelling.

WingArea:

        The area of the wing.


public static class

Kinematics




public const int

kVelocityRatio

Convert inspector speed to m/s.



public static bool

HasReached (Vector3 From, Vector3 To, float Tolerance)

Summary:

If the distance between From and To is <= Tolerance.

Params:

From:

        The reference Vector3 to compare.

To:

        The target Vector3 to compare.

Tolerance:

        The range that is considered if From has 'reached' To.

Returns:

True if the distance between From and To are <= Tolerance.



public static void

HomeTowards (Rigidbody Rigidbody, Transform Target, float Velocity, float MaxDegreesDeltaPerFrame)

Summary:

Moves Rigidbody towards target while moving at velocity with a maximum turn angle of MaxDegreesDeltaPerFrame.

Params:

Rigidbody:

        The Rigidbody to move.

Target:

        The Transform destination.

Velocity:

        The rate at which self moves towards target.

MaxDegreesDeltaPerFrame:

        The maximum degrees self can turn towards target per frame.



public static void

HomeTowards (Rigidbody Rigidbody, Vector3 Target, float Velocity, float MaxDegreesDeltaPerFrame)

Summary:

Moves Rigidbody towards target while moving at velocity with a maximum turn angle of MaxDegreesDeltaPerFrame.

Params:

Rigidbody:

        The Rigidbody to move.

Target:

        The destination coordinates.

Velocity:

        The rate at which self moves towards target.

MaxDegreesDeltaPerFrame:

        The maximum degrees self can turn towards target per frame.



public static void

HomeTowards (Rigidbody2D Rigidbody, Transform Target, float Velocity, float MaxDegreesDeltaPerFrame)

Summary:

Moves Rigidbody towards target while moving at velocity with a maximum turn angle of MaxDegreesDeltaPerFrame.

Params:

Rigidbody:

        The Rigidbody2D to move.

Target:

        The Transform destination.

Velocity:

        The rate at which self moves towards target.

MaxDegreesDeltaPerFrame:

        The maximum degrees self can turn towards target per frame.



public static void

HomeTowards (Rigidbody2D Rigidbody, Vector3 Target, float Velocity, float MaxDegreesDeltaPerFrame)

Summary:

Moves Rigidbody towards target while moving at velocity with a maximum turn angle of MaxDegreesDeltaPerFrame.

Params:

Rigidbody:

        The Rigidbody2D to move.

Target:

        The destination coordinates.

Velocity:

        The rate at which self moves towards target.

MaxDegreesDeltaPerFrame:

        The maximum degrees self can turn towards target per frame.



public static bool

LaunchTowards (MVector& LaunchVelocity, MVector Origin, MVector Target, float LaunchSpeed, bool bFavourHighArc, bool bIs3D, bool bDrawDebug)

Summary:

Calculates a launch velocity towards a target at a given speed.

Params:

LaunchVelocity:

        The out velocity of the launch.

Origin:

        Where the launch will begin.

Target:

        The intended destination of the launched projectile.

LaunchSpeed:

        The speed of the launched projectile.

bFavourHighArc:

        Should the launched projectile attain the maximum height?

bIs3D:

        True if using 3D physics.

bDrawDebug:

        True to draw debug lines of the arc.

Returns:

True if a solution to hit Target from Origin at LaunchSpeed exists.



public static MVector

LaunchTowards (MVector Origin, MVector Target, float TargetHeight, float& Time, bool b3DGravity, bool bLaunchRegardless)

Summary:

Computes a velocity to launch a Rigidbody from Origin to Target achieving a TargetHeight.

Remarks:

Will not compute if TargetHeight cannot reach To.y and bLaunchRegardless is false.

Params:

Origin:

        Where to launch from.

Target:

        Where to launch to.

TargetHeight:

        The apex.

Time:

        Point on launch trajectory at a time. Flight time.

b3DGravity:

        True if using 3D Physics.

bLaunchRegardless:

        True to ignore the height limitation and compute a velocity anyway.

Returns:

The velocity required to launch a projectile from Origin to Target, or MVector.NaN if impossible.



public static MVector

LaunchTowards (MVector Origin, MVector Target, float TargetHeight, float GravityMagnitude, float& Time, bool bLaunchRegardless, bool b3DGravity)

Summary:

Computes a velocity to launch a Rigidbody from Origin to Target achieving a TargetHeight.

Remarks:

Will not compute if TargetHeight cannot reach To.y and bLaunchRegardless is false.

Params:

Origin:

        Where to launch from.

Target:

        Where to launch to.

TargetHeight:

        The apex.

GravityMagnitude:

        True if using 3D Physics.

Time:

        Point on launch trajectory at a time. Flight time.

bLaunchRegardless:

        True to ignore the height limitation and compute a velocity anyway.

b3DGravity:

        True if using 3D Physics.

Returns:

The velocity required to launch a projectile from Origin to Target, or MVector.NaN if impossible.



public static MVector

LaunchTowards (MVector Origin, MVector Target, float TargetHeight, float GravityMagnitude, float& Time, MVector[]& Arc, int ArcResolution, bool bLaunchRegardless, bool b3DGravity)

Summary:

Computes a velocity to launch a Rigidbody from Origin to Target achieving a TargetHeight.

Remarks:

Will not compute if TargetHeight cannot reach To.y and bLaunchRegardless is false.

Params:

Origin:

        Where to launch from.

Target:

        Where to launch to.

TargetHeight:

        The apex.

GravityMagnitude:

        True if using 3D Physics.

Time:

        Point on launch trajectory at a time. Flight time.

Arc:

        Out the points in a line where the projectile will follow from Origin to Target.

ArcResolution:

        The number of points for the Arc.

bLaunchRegardless:

        True to ignore the height limitation and compute a velocity anyway.

b3DGravity:

        True if using 3D Physics.

Returns:

The velocity required to launch a projectile from Origin to Target, or MVector.NaN if impossible.



public static MVector[]

GetArc (MVector LaunchVelocity, float Time, int ArcResolution, bool bIs3D)

Summary:

Gets the Arc of a launched projectile, given the time.

Params:

LaunchVelocity:

        The speed and direction of the launched projectile.

Time:

        Flight time.

ArcResolution:

        The number of points for the Arc.

bIs3D:

        True if using 3D Physics.

Returns:

The trajectory of a projectile travelling at LaunchVelocity will travel through.



public static MArray

GetProjectileArc (Rigidbody Physics, Vector3 StartPosition, float Gravity, int Resolution, bool bDrawDebug, float MaxSimulationTime)

Summary:

The Arc of a Projectile travelling through the world.

Params:

Physics:

        The Rigidbody associated with a Projectile.

StartPosition:

        The initial position of the Projectile.

Gravity:

        The pull of Gravity affecting this Projectile.

Resolution:

        The number of points to sample the trajectory.

bDrawDebug:

        True to draw debug lines of the Projectile's trajectory.

MaxSimulationTime:

        The maximum time-step for the trajectory simulation.

Returns:

An array of this Projectile's Position and velocity at the given Time.



public static MArray

GetProjectileArc (MVector Velocity, MVector StartPosition, float Gravity, int Resolution, bool bDrawDebug, float MaxSimulationTime)

Summary:

The Arc of a Projectile travelling through the world.

Params:

Velocity:

        The speed and direction of this Projectile.

StartPosition:

        The initial position of the Projectile.

Gravity:

        The pull of Gravity affecting this Projectile.

Resolution:

        The number of points to sample the trajectory.

bDrawDebug:

        True to draw debug lines of the Projectile's trajectory.

MaxSimulationTime:

        The maximum time-step for the trajectory simulation.

Returns:

An array of this Projectile's Position and velocity at the given Time.



public static bool

GetProjectileArc (Rigidbody Physics, Vector3 StartPosition, float Gravity, MArray<ProjectileArcTracer>& Trajectory, float ProjectileRadius, LayerMask CollisionLayer, MArray<ProjectileArcCollision>& Collisions, bool bStopOnCollision, int Resolution, bool bDrawDebug, float MaxSimulationTime)

Summary:

The Arc of a Projectile travelling through the world.

Params:

Physics:

        The Rigidbody associated with a Projectile.

StartPosition:

        The initial position of the Projectile.

Gravity:

        The pull of Gravity affecting this Projectile.

Trajectory:

        Outs an array of this Projectile's Position and velocity at the given Time.

ProjectileRadius:

        The radius of this Projectile to consider for Collisions.

CollisionLayer:

        The Layer to identify Collisions.

Collisions:

        Outs an array of the Collisions this Projectile will encounter along the trajectory.

bStopOnCollision:

        True to stop simulating and calculating the trajectory upon Collision.

Resolution:

        The number of points to sample the trajectory.

bDrawDebug:

        True to draw debug lines of the Projectile's trajectory and Collisions.

MaxSimulationTime:

        The maximum time-step for the trajectory simulation.

Returns:

True if this Projectile will Collide with something in CollisionLayer.



public static bool

GetProjectileArc (GameObject Projectile, MVector Velocity, Vector3 StartPosition, float Gravity, MArray<ProjectileArcTracer>& Trajectory, float ProjectileRadius, LayerMask CollisionLayer, MArray<ProjectileArcCollision>& Collisions, bool bStopOnCollision, int Resolution, bool bDrawDebug, float MaxSimulationTime)

Summary:

The Arc of a Projectile travelling through the world.

Params:

Projectile:

        This Projectile; ignored when checking for Collisions.

Velocity:

        The speed and direction of this Projectile.

StartPosition:

        The initial position of the Projectile.

Gravity:

        The pull of Gravity affecting this Projectile.

Trajectory:

        Outs an array of this Projectile's Position and velocity at the given Time.

ProjectileRadius:

        The radius of this Projectile to consider for Collisions.

CollisionLayer:

        The Layer to identify Collisions.

Collisions:

        Outs an array of the Collisions this Projectile will encounter along the trajectory.

bStopOnCollision:

        True to stop simulating and calculating the trajectory upon Collision.

Resolution:

        The number of points to sample the trajectory.

bDrawDebug:

        True to draw debug lines of the Projectile's trajectory and Collisions.

MaxSimulationTime:

        The maximum time-step for the trajectory simulation.

Returns:

True if this Projectile will Collide with something in CollisionLayer.



public static MVector

V_GForce (MVector LastPosition, MVector ThisPosition, float DeltaTime, MVector Gravity)

Summary:

The G Force experienced by a GameObject between two positions over DeltaTime, under the pull of Gravity.

Params:

LastPosition:

        The position before the current FixedUpdate call.

ThisPosition:

        The current position at this FixedUpdate call.

DeltaTime:

        The time between recording LastPosition and ThisPosition.

Gravity:

        The force of Gravity.

Returns:

The direction/s of the G Force.



public static float

F_GForce (MVector LastPosition, MVector ThisPosition, float DeltaTime, MVector Gravity)

Summary:

The G Force experienced by a GameObject between two positions over DeltaTime, under the pull of Gravity.

Params:

LastPosition:

        The position before the current FixedUpdate call.

ThisPosition:

        The current position at this FixedUpdate call.

DeltaTime:

        The time between recording LastPosition and ThisPosition.

Gravity:

        The force of Gravity.

Returns:

The G Force without an associated direction.



public static MVector

ComputeJumpVelocity (MVector Up, float TargetHeight, bool b3DGravity)

Summary:

Compute the required velocity to jump at TargetHeight.

Params:

Up:

        Normalised direction of jumping.

TargetHeight:

        The peak height achieved by this velocity.

b3DGravity:

        True if using 3D Physics.

Returns:

The velocity required to jump Up at TargetHeight high.



public static MVector

ComputeJumpVelocity (MVector Up, float TargetHeight, float GravityMagnitude)

Summary:

Compute the required velocity to jump at TargetHeight.

Params:

Up:

        Normalised direction of jumping.

TargetHeight:

        The peak height achieved by this velocity.

GravityMagnitude:

        The pull of gravity in opposite Up.

Returns:

The velocity required to jump Up at TargetHeight high.


public struct

ProjectileArcTracer


Projectile trajectory information.



public MVector

Position

Te world-position of this trace at Time.



public MVector

Velocity

The speed and direction of this trace at Time.



public float

Time

The Position and Velocity of the trajectory at this Time.


public struct

ProjectileArcCollision


Projectile trajectory impacts information.



public MVector

Point

The world-position of the Collision.



public MVector

Velocity

The speed and direction of the Collision.



public Collider

Collider

The impacting Collider.


public static class

Miscellanous




public static Vector3

CollisionAvoidance (Transform Self, float Angle, float SearchDistance, LayerMask Obstacles, bool bDebug)

Summary:

The direction in which to avoid colliding with obstacles.

Params:

Self:

        The transform wanting to avoid collisions.

Angle:

        The angle to search for potential collisions.

SearchDistance:

        The distance to search for collisions.

Obstacles:

        The layer to avoid colliding with.

bDebug:

        [EDITOR ONLY] Draw lines of the collision avoidance search. Red is the closest collision. Blue is the moving forward direction.