<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>https://rage.grandroleplay.ru/index.php?action=history&amp;feed=atom&amp;title=Raycasting%3A%3AtestPointToPoint</id>
	<title>Raycasting::testPointToPoint - История изменений</title>
	<link rel="self" type="application/atom+xml" href="https://rage.grandroleplay.ru/index.php?action=history&amp;feed=atom&amp;title=Raycasting%3A%3AtestPointToPoint"/>
	<link rel="alternate" type="text/html" href="https://rage.grandroleplay.ru/index.php?title=Raycasting::testPointToPoint&amp;action=history"/>
	<updated>2026-07-24T19:12:35Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://rage.grandroleplay.ru/index.php?title=Raycasting::testPointToPoint&amp;diff=13952&amp;oldid=prev</id>
		<title>imported&gt;Shr0x: /* See also */</title>
		<link rel="alternate" type="text/html" href="https://rage.grandroleplay.ru/index.php?title=Raycasting::testPointToPoint&amp;diff=13952&amp;oldid=prev"/>
		<updated>2025-03-16T17:42:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;See also&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{ClientsideJsFunction}}&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
This function casts a ray from Point1 to Point2 and returns the position and entity of what&amp;#039;s in the way, or undefined if the way is cleared.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;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.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Flags:&amp;lt;br&amp;gt;1: Intersect with map&amp;lt;br&amp;gt;2: Intersect with vehicles (used to be mission entities?) (includes train)&amp;lt;br&amp;gt;4: Intersect with peds? (same as 8)&amp;lt;br&amp;gt;8: Intersect with peds? (same as 4)&amp;lt;br&amp;gt;16: Intersect with objects&amp;lt;br&amp;gt;32: Unknown&amp;lt;br&amp;gt;64: Unknown&amp;lt;br&amp;gt;128: Unknown&amp;lt;br&amp;gt;256: Intersect with vegetation (plants, coral. trees not included)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;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. &lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mp.raycasting.testPointToPoint(pos1, pos2, [ignoredEntity], [flags])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Required arguments ===&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;pos1:&amp;#039;&amp;#039;&amp;#039; Vector3&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;pos2:&amp;#039;&amp;#039;&amp;#039; Vector3&lt;br /&gt;
&lt;br /&gt;
=== Optional arguments ===&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;ignoredEntity:&amp;#039;&amp;#039;&amp;#039; Entity handle or object - example: mp.players.local&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;flags:&amp;#039;&amp;#039;&amp;#039; Int representing sum of flags - example: 17 (intersect with map [1] and objects [16])&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
*&amp;#039;&amp;#039;&amp;#039;object&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Example of return object&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
	&amp;quot;position&amp;quot;: {&lt;br /&gt;
		&amp;quot;x&amp;quot;: 13.01,&lt;br /&gt;
		&amp;quot;y&amp;quot;: 12.23,&lt;br /&gt;
		&amp;quot;z&amp;quot;: 70.02&lt;br /&gt;
	},&lt;br /&gt;
	&amp;quot;surfaceNormal&amp;quot;: {&lt;br /&gt;
		&amp;quot;x&amp;quot;: 0.93,&lt;br /&gt;
		&amp;quot;y&amp;quot;: -0.04,&lt;br /&gt;
		&amp;quot;z&amp;quot;: -0.34&lt;br /&gt;
	},&lt;br /&gt;
	&amp;quot;entity&amp;quot;: &amp;lt;entity object&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
{{ClientsideCode|&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mp.events.add(&amp;#039;render&amp;#039;, () =&amp;gt; {&lt;br /&gt;
	const startPosition = mp.players.local.getBoneCoords(12844, 0.5, 0, 0);&lt;br /&gt;
	const endPosition = new mp.Vector3(0, 0, 75);&lt;br /&gt;
&lt;br /&gt;
	const hitData = mp.raycasting.testPointToPoint(startPosition, endPosition);&lt;br /&gt;
	if (!hitData) {&lt;br /&gt;
		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&lt;br /&gt;
	} else {&lt;br /&gt;
		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&lt;br /&gt;
	}&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This function returns undefined or a valid result, if you point with your camera on something. &lt;br /&gt;
{{ClientsideCode|&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function pointingAt(distance) {&lt;br /&gt;
    const camera = mp.cameras.new(&amp;quot;gameplay&amp;quot;); // gets the current gameplay camera&lt;br /&gt;
&lt;br /&gt;
    let position = camera.getCoord(); // grab the position of the gameplay camera as Vector3&lt;br /&gt;
&lt;br /&gt;
    let direction = camera.getDirection(); // get the forwarding vector of the direction you aim with the gameplay camera as Vector3&lt;br /&gt;
&lt;br /&gt;
    let farAway = new mp.Vector3((direction.x * distance) + (position.x), (direction.y * distance) + (position.y), (direction.z * distance) + (position.z)); // calculate a random point, drawn on a invisible line between camera position and direction (* distance)&lt;br /&gt;
&lt;br /&gt;
    let result = mp.raycasting.testPointToPoint(position, farAway, null, 17); // now test point to point - intersects with map and objects [1 + 16]&lt;br /&gt;
&lt;br /&gt;
    return result; // and return the result ( undefined, if no hit )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{Raycast_functions_c}}&lt;br /&gt;
[[Category:Clientside API]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Shr0x</name></author>
	</entry>
</feed>