[**SixL client API**](../../README.md)

***

[SixL client API](../../README.md) / [raycasting](../README.md) / 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

```ts
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`](RaycastResult.md)\>

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

#### Parameters

##### startPos

[`IVector3`](../../common/interfaces/IVector3.md)

Where it starts.

##### endPos

[`IVector3`](../../common/interfaces/IVector3.md)

Where it ends.

##### radius

`number`

The radius, in metres.

##### ignoreEntity?

[`EntityMp`](../../entity/interfaces/EntityMp.md) \| [`EntityMp`](../../entity/interfaces/EntityMp.md)[]

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`](RaycastResult.md)\>

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

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

***

### testPointToPoint()

> **testPointToPoint**(`startPos`, `endPos`, `ignoreEntity?`, `flags?`): `Promise`\<[`RaycastResult`](RaycastResult.md)\>

Casts a ray from one point to another.

#### Parameters

##### startPos

[`IVector3`](../../common/interfaces/IVector3.md)

Where the ray starts.

##### endPos

[`IVector3`](../../common/interfaces/IVector3.md)

Where it ends.

##### ignoreEntity?

[`EntityMp`](../../entity/interfaces/EntityMp.md) \| [`EntityMp`](../../entity/interfaces/EntityMp.md)[]

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`](RaycastResult.md)\>

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

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

***

### testPointToPointAsync()

> **testPointToPointAsync**(`startPos`, `endPos`, `ignoreEntity?`, `flags?`): `Promise`\<[`RaycastResult`](RaycastResult.md)\>

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`](../../common/interfaces/IVector3.md)

Where the ray starts.

##### endPos

[`IVector3`](../../common/interfaces/IVector3.md)

Where it ends.

##### ignoreEntity?

[`EntityMp`](../../entity/interfaces/EntityMp.md) \| [`EntityMp`](../../entity/interfaces/EntityMp.md)[]

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`](RaycastResult.md)\>

A Promise of the hit, or undefined.

#### Remarks

Partial: not yet confirmed in the game.

#### Example

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