Entity::setNoCollision: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Calling this function, regardless of the 'unknown' value, disabled collision between two entities.<br><br>Importance of entity1 and 2 order is unclear.
Calling this function, regardless of the 'unknown' value, disabled collision between two entities.<br><br>Importance of entity1 and 2 order is unclear.
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">entity.setNoCollision(entity2, collision);</syntaxhighlight>
<pre>entity.setNoCollision(entity2, enableThisFrame);</pre>
 
=== Required Arguments ===
=== Required Arguments ===
*'''entity2:''' Entity handle or object
*'''entity2:''' '''Entity handle'''
*'''collision:''' Boolean
*'''enableThisFrame:''' '''Boolean'''
** '''false''' = disabled forever, '''true''' = disabled only this frame
 
===Return value===
===Return value===
*'''Undefined'''
*'''Undefined'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
{{ClientsideCode|
// todo
<pre>
</syntaxhighlight>
//to re-enable collision just stop executing the code, the game will re-enable it on its own.
mp.events.add('render', () => {
if (!mp.players.local.vehicle) return;
mp.players.forEachInRange(mp.players.local.position, 50, (target) => {
if (!target.vehicle) return;
mp.players.local.vehicle.setNoCollision(target.vehicle.handle, true);
target.vehicle.setNoCollision(mp.players.local.vehicle.handle, true);
});
});
 
</pre>
}}
 
==See also==
==See also==
{{Entity_function_c}}
{{Entity_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 18:03, 1 May 2024

Calling this function, regardless of the 'unknown' value, disabled collision between two entities.

Importance of entity1 and 2 order is unclear.

Syntax

entity.setNoCollision(entity2, enableThisFrame);

Required Arguments

  • entity2: Entity handle
  • enableThisFrame: Boolean
    • false = disabled forever, true = disabled only this frame

Return value

  • Undefined

Example

Client-Side
//to re-enable collision just stop executing the code, the game will re-enable it on its own.
mp.events.add('render', () => {
	if (!mp.players.local.vehicle) return;
	mp.players.forEachInRange(mp.players.local.position, 50, (target) => {
		if (!target.vehicle) return;
		mp.players.local.vehicle.setNoCollision(target.vehicle.handle, true);
		target.vehicle.setNoCollision(mp.players.local.vehicle.handle, true);
	});
});

See also