Camera::pointAtPedBone: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
m (Replaced HTML with template)
 
Line 4: Line 4:


==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">camera.pointAtPedBone(ped, boneIndex, x, y, z, p6);</syntaxhighlight>
<pre>camera.pointAtPedBone(ped, boneIndex, x, y, z, p6);</pre>
 
=== Required Arguments ===
=== Required Arguments ===
*'''ped:''' int
*'''ped:''' int
Line 12: Line 13:
*'''z:''' float
*'''z:''' float
*'''p6:''' Boolean (The bool p6 is unknown, but through every X360 script it's always 1.)
*'''p6:''' Boolean (The bool p6 is unknown, but through every X360 script it's always 1.)
===Return value===
===Return value===
*'''Undefined'''
*'''Undefined'''
==Example==
==Example==
This event locks the camera onto the players hand.
This event locks the camera onto the players hand.


<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
{{ClientsideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<pre>
<syntaxhighlight lang="javascript">
let handCamera = mp.cameras.new('default', new mp.Vector3(0,  0,  0), new mp.Vector3(0,0,0), 40);
let handCamera = mp.cameras.new('default', new mp.Vector3(0,  0,  0), new mp.Vector3(0,0,0), 40);


Line 30: Line 32:
     mp.game.cam.renderScriptCams(true, false, 0, true, false);
     mp.game.cam.renderScriptCams(true, false, 0, true, false);
});
});
</syntaxhighlight>
</pre>
</div>
}}


==See also==
==See also==
{{Camera_definition_c}}
{{Camera_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]

Latest revision as of 13:18, 26 October 2018

Sets the camera so it's pointing towards a ped's bone.

Bones List: Bones

Syntax

camera.pointAtPedBone(ped, boneIndex, x, y, z, p6);

Required Arguments

  • ped: int
  • boneIndex: int
  • x: float
  • y: float
  • z: float
  • p6: Boolean (The bool p6 is unknown, but through every X360 script it's always 1.)

Return value

  • Undefined

Example

This event locks the camera onto the players hand.

Client-Side
let handCamera = mp.cameras.new('default', new mp.Vector3(0,  0,  0), new mp.Vector3(0,0,0), 40);

mp.events.add("handCam", () => {
    let playerPosition = mp.players.local.position
    
    handCamera.setActive(true);
    handCamera.pointAtPedBone(mp.players.local.handle, 57005, 0, 0, 0, true);
    handCamera.setCoord(playerPosition.x + 1, playerPosition.y + 1, playerPosition.z);
    mp.game.cam.renderScriptCams(true, false, 0, true, false);
});

See also