SixL client API / raycasting / RaycastingMp

Interface: RaycastingMp

Ray tests in the game's world: mp.raycasting.

Remarks

The game answers a test on a later frame, so every test returns a Promise (RAGE MP's answer at once). A test answers undefined when it hits nothing.

Example

const hit = await mp.raycasting.testPointToPoint(mp.players.local.position, new mp.Vector3(0, 0, 0));

Methods

testCapsule()

testCapsule(startPos, endPos, radius, ignoreEntity?, flags?): Promise<RaycastResult>

Sweeps a capsule (a ray with a radius) from one point to another.

Parameters

startPos

IVector3

Where it starts.

endPos

IVector3

Where it ends.

radius

number

The radius, in metres.

ignoreEntity?

EntityMp | EntityMp[]

An entity it passes through (of several, the first).

flags?

number | number[]

What it can hit, as the game's flags (several are combined); all kinds when left out.

Returns

Promise<RaycastResult>

A Promise of the hit, or undefined.

Remarks

Not working yet: in the game it answers undefined until the capsule test is supported (the line tests work).

Example

const hit = await mp.raycasting.testCapsule(from, to, 0.5);

testPointToPoint()

testPointToPoint(startPos, endPos, ignoreEntity?, flags?): Promise<RaycastResult>

Casts a ray from one point to another.

Parameters

startPos

IVector3

Where the ray starts.

endPos

IVector3

Where it ends.

ignoreEntity?

EntityMp | EntityMp[]

An entity the ray passes through (of several, the first).

flags?

number | number[]

What the ray can hit, as the game's flags (several are combined); all kinds when left out.

Returns

Promise<RaycastResult>

A Promise of the hit, or undefined.

Remarks

Partial: not yet confirmed in the game. The game answers within the frame of the test.

Example

const hit = await mp.raycasting.testPointToPoint(from, to, mp.players.local);

testPointToPointAsync()

testPointToPointAsync(startPos, endPos, ignoreEntity?, flags?): Promise<RaycastResult>

Casts a ray from one point to another: the same test as testPointToPoint (the game answers a test only in the frame it is made in).

Parameters

startPos

IVector3

Where the ray starts.

endPos

IVector3

Where it ends.

ignoreEntity?

EntityMp | EntityMp[]

An entity the ray passes through (of several, the first).

flags?

number | number[]

What the ray can hit, as the game's flags (several are combined); all kinds when left out.

Returns

Promise<RaycastResult>

A Promise of the hit, or undefined.

Remarks

Partial: not yet confirmed in the game.

Example

const hit = await mp.raycasting.testPointToPointAsync(from, to);