Skip to content
On this page

AthenaShared.utility.vector

References

DirectionVector

Re-exports DirectionVector

Functions

distance

Usage

AthenaShared.utility.vector.distance(vector1, vector2): number

Get the distance between two positions.

Parameters

NameType
vector1IVector3
vector2IVector3

Returns

number

Defined in

shared/utility/vector.ts:12


distance2d

Usage

AthenaShared.utility.vector.distance2d(vector1, vector2): number

Get the distance between two positions. Excludes z

Parameters

NameType
vector1IVector2
vector2IVector2

Returns

number

Defined in

shared/utility/vector.ts:30


getClosestEntity

Usage

AthenaShared.utility.vector.getClosestEntity<T>(playerPosition, rot, entities, dist, checkBackwards?): T | null

Get the closest server entity type. Server only.

Type parameters

Name
T

Parameters

NameTypeDefault valueDescription
playerPositionIVector3undefined
rotIVector3undefinedplayer rotation
entities{ pos: IVector3 ; valid?: boolean }[]undefined
distnumberundefined-
checkBackwardsbooleanfalse-

Returns

T | null

Defined in

shared/utility/vector.ts:209


getClosestOfType

Usage

AthenaShared.utility.vector.getClosestOfType<T>(pos, elements, lastDistance?): T | undefined

Get the closest of a specific type of object with a pos property.

Type parameters

NameType
T{ pos: IVector3 }

Parameters

NameTypeDefault valueDescription
posIVector3undefinedA position in the world.
elementsreadonly T & { pos: IVector3 }[]undefined
lastDistancenumber100

Returns

T | undefined

Defined in

shared/utility/vector.ts:298


getClosestTypes

Usage

AthenaShared.utility.vector.getClosestTypes<T>(pos, elements, maxDistance, mustHaveProperties?, positionName?): T[]

Gets an array of the closest types.

Type parameters

NameType
Textends Object

Parameters

NameTypeDefault valueDescription
posIVector3undefinedA position in the world.
elementsT[]undefined
maxDistancenumberundefined
mustHavePropertiesstring[][]-
positionNamestring'pos'-

Returns

T[]

Defined in

shared/utility/vector.ts:81


getClosestVector

Usage

AthenaShared.utility.vector.getClosestVector(pos, arrayOfPositions): IVector3

Get the closest vector given an array of positions.

Parameters

NameTypeDescription
posIVector3A position in the world.
arrayOfPositionsIVector3[]

Returns

IVector3

Defined in

shared/utility/vector.ts:46


getClosestVectorByPos

Usage

AthenaShared.utility.vector.getClosestVectorByPos<T>(pos, arrayOfPositions, posVariable?): T

Get the closest Vector by position.

Type parameters

Name
T

Parameters

NameTypeDefault valueDescription
posIVector3undefinedA position in the world.
arrayOfPositionsT[]undefined
posVariable?string'pos'

Returns

T

Defined in

shared/utility/vector.ts:64


getForwardVector

Usage

AthenaShared.utility.vector.getForwardVector(rot): alt.IVector3

SERVER ONLY Gets the direction the player is facing.

Parameters

NameType
rotIVector3

Returns

alt.IVector3

Defined in

shared/utility/vector.ts:157


getVectorInFrontOfPlayer

Usage

AthenaShared.utility.vector.getVectorInFrontOfPlayer(entity, distance): alt.Vector3

SERVER ONLY Return a position in front of a player based on distance.

Parameters

NameType
entityObject
entity.posIVector3
entity.rotIVector3
distancenumber

Returns

alt.Vector3

Defined in

shared/utility/vector.ts:173


isBetweenVectors

Usage

AthenaShared.utility.vector.isBetweenVectors(pos, vector1, vector2): boolean

Determine if a vector is between vectors.

Parameters

NameTypeDescription
posIVector3A position in the world.
vector1IVector3
vector2IVector3

Returns

boolean

Defined in

shared/utility/vector.ts:194


lerp

Usage

AthenaShared.utility.vector.lerp(a, b, t): number

Parameters

NameType
anumber
bnumber
tnumber

Returns

number

Defined in

shared/utility/vector.ts:119


vectorLerp

Usage

AthenaShared.utility.vector.vectorLerp(start, end, l, clamp): alt.IVector3

Finds a position between two vectors to ease into. Returns a new position.

Parameters

NameType
startIVector3
endIVector3
lnumber
clampboolean

Returns

alt.IVector3

Defined in

shared/utility/vector.ts:134

Created by Stuyk | Est. 2020