Entity::attachTo: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Attaches entity1 to bone (boneIndex) of entity2.<br><br>boneIndex - this is different to boneID, use GET_Player_BONE_INDEX to get the index from the ID. use the index for attaching to specific bones. entity1 will be attached to entity2's centre if bone index given doesn't correspond to bone indexes for that entity type.<br><br>useSoftPinning - if set to false attached entity will not detach when fixed<br>collision - controls collision between the two entities (FALSE disables collision).<br>isPed - pitch doesnt work when false and roll will only work on negative numbers (only peds)<br>vertexIndex - position of vertex<br>fixedRot - if false it ignores entity vector <br>
Attaches entity1 to bone (boneIndex) of entity2.<br><br>boneIndex - this is different to boneID, use GET_Player_BONE_INDEX to get the index from the ID. use the index for attaching to specific bones. entity1 will be attached to entity2's centre if bone index given doesn't correspond to bone indexes for that entity type.<br><br>useSoftPinning - if set to false attached entity will not detach when fixed<br>collision - controls collision between the two entities (FALSE disables collision).<br>isPed - pitch doesnt work when false and roll will only work on negative numbers (only peds)<br>vertexIndex - position of vertex<br>fixedRot - if false it ignores entity vector <br><br>
<b>Note:</b><br/>
On 1.1 you cannot instantly attach an object to any entity after creating. You need to use it after a timeout (100-200 ms) or entityStreamIn.
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">entity.attachTo(entity2, boneIndex, xPosOffset, yPosOffset, zPosOffset, xRot, yRot, zRot, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);</syntaxhighlight>
<syntaxhighlight lang="javascript">entity.attachTo(entity2, boneIndex, xPosOffset, yPosOffset, zPosOffset, xRot, yRot, zRot, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);</syntaxhighlight>
=== Required Arguments ===
=== Required Arguments ===
*'''entity2:''' Entity handle ( or object, actually it only accepts handles, so use for example player.handle )
*'''entity2:''' Entity handle ( so use for example player.handle )
*'''boneIndex:''' int
*'''boneIndex:''' int
*'''xPosOffset:''' float
*'''xPosOffset:''' float
Line 22: Line 25:


==Example==
==Example==
{{JSContainer|
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">


Line 27: Line 31:
criminal.attachTo(cop.handle, 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0, false);
criminal.attachTo(cop.handle, 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0, false);
  });
  });
</syntaxhighlight>
</syntaxhighlight>
}}


==See also==
==See also==
{{Entity_function_c}}
{{Entity_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 18:01, 1 May 2024

Attaches entity1 to bone (boneIndex) of entity2.

boneIndex - this is different to boneID, use GET_Player_BONE_INDEX to get the index from the ID. use the index for attaching to specific bones. entity1 will be attached to entity2's centre if bone index given doesn't correspond to bone indexes for that entity type.

useSoftPinning - if set to false attached entity will not detach when fixed
collision - controls collision between the two entities (FALSE disables collision).
isPed - pitch doesnt work when false and roll will only work on negative numbers (only peds)
vertexIndex - position of vertex
fixedRot - if false it ignores entity vector

Note:
On 1.1 you cannot instantly attach an object to any entity after creating. You need to use it after a timeout (100-200 ms) or entityStreamIn.

Syntax

entity.attachTo(entity2, boneIndex, xPosOffset, yPosOffset, zPosOffset, xRot, yRot, zRot, p9, useSoftPinning, collision, isPed, vertexIndex, fixedRot);

Required Arguments

  • entity2: Entity handle ( so use for example player.handle )
  • boneIndex: int
  • xPosOffset: float
  • yPosOffset: float
  • zPosOffset: float
  • xRot: float
  • yRot: float
  • zRot: float
  • p9: Boolean
  • useSoftPinning: Boolean
  • collision: Boolean
  • isPed: Boolean
  • vertexIndex: int
  • fixedRot: Boolean

Return value

  • Undefined

Example

JavaScript Syntax

 mp.events.add('arrestAttach', (cop, criminal) => {
	criminal.attachTo(cop.handle, 0, 0, 0, 0, 0, 0, 0, true, false, false, false, 0, false);
 });


See also