Raycasting::TestPointToPoint: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
Line 11: Line 11:
*'''object'''
*'''object'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
// todo
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<syntaxhighlight lang="javascript" highlight="5">
let checkResolution = () => {
let res = mp.game.graphics.getScreenActiveResolution(x, y);
        if (typeof mp.raycasting.testPointToPoint(player.getBoneCoords(12844, 0, 0, 0), new mp.Vector3(x, y, z)) === 'undefined') {
// Is in line of sight
}
        else
        {
// Is NOT in line of sight
 
        }
};
 
checkResolution();
</syntaxhighlight>
</syntaxhighlight>
</div>
==See also==
==See also==
{{Worldprobe_s_function_c}}
{{Worldprobe_s_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Revision as of 02:35, 24 November 2017

This function casts a ray from Point1 to Point2 and returns the position and entity of what's in the way, or undefined if the way is cleared.

Flags are intersection bit flags. They tell the ray what to care about and what not to care about when casting. Passing -1 will intersect with everything, presumably.

Flags:
1: Intersect with map
2: Intersect with vehicles (used to be mission entities?) (includes train)
4: Intersect with peds? (same as 8)
8: Intersect with peds? (same as 4)
16: Intersect with objects
32: Unknown
64: Unknown
128: Unknown
256: Intersect with vegetation (plants, coral. trees not included)

NOTE: Raycasts that intersect with mission_entites (flag = 2) has limited range and will not register for far away entites. The range seems to be about 30 metres.

BEFORE DP2: Before (and maybe after) DP2, the ignoreEntity argument does not work. Also this function should return an object with positions and entity if the line intersected with an entity, but it only gives positions, not the entityHandle. It returns nothing (undefined) if the 2 points are in line of sight.

Syntax

mp.raycasting.testPointToPoint(pos1, pos2[, ignoredEntity][, flags]);

Required Arguments

  • pos1: Vector3
  • pos2: Vector3
  • ignoreEntity: Entity handle or object
  • flags: array

Return value

  • object

Example

Client-Side
let checkResolution = () => {
	let res = mp.game.graphics.getScreenActiveResolution(x, y);
	
        if (typeof mp.raycasting.testPointToPoint(player.getBoneCoords(12844, 0, 0, 0), new mp.Vector3(x, y, z)) === 'undefined') {
		// Is in line of sight
	}
        else
        {
		// Is NOT in line of sight

        }
};

checkResolution();

See also

Template:Worldprobe s function c