Raycasting::testCapsule: Difference between revisions
(Created page with "Raycast from point to point, where the ray has a radius. ==Syntax== <syntaxhighlight lang="javascript">mp.raycasting.testCapsule(pos1, pos2, radius[, ignoredEntity][, flags])...") |
No edit summary |
||
| Line 7: | Line 7: | ||
*'''radius:''' Float | *'''radius:''' Float | ||
*'''ignoreEntity:''' Entity handle or object | *'''ignoreEntity:''' Entity handle or object | ||
*'''flags:''' | *'''flags:''' Int | ||
===Return value=== | ===Return value=== | ||
*'''object:''' position, surfaceNormal, material, entity | *'''object:''' position, surfaceNormal, material, entity | ||
Revision as of 09:21, 13 January 2018
Raycast from point to point, where the ray has a radius.
Syntax
mp.raycasting.testCapsule(pos1, pos2, radius[, ignoredEntity][, flags]);
Required Arguments
- pos1: Vector3
- pos2: Vector3
- radius: Float
- ignoreEntity: Entity handle or object
- flags: Int
Return value
- object: position, surfaceNormal, material, entity
Example
Client-Side
mp.events.add('render', () => {
const startPosition = player.getBoneCoords(12844, 0.5, 0, 0);
const endPosition = new mp.Vector3(0, 0, 75);
const hitData = mp.raycasting.testCapsule(startPosition, endPosition, 0.5);
if (!hitData) {
mp.game.graphics.drawLine(startPosition.x, startPosition.y, startPosition.z, endPosition.x, endPosition.y, endPosition.z, 255, 255, 255, 255); // Is in line of sight
} else {
mp.game.graphics.drawLine(startPosition.x, startPosition.y, startPosition.z, endPosition.x, endPosition.y, endPosition.z, 255, 0, 0, 255); // Is NOT in line of sight
}
});