Camera::attachToPedBone: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
(Added example, cleaned up page.)
Line 1: Line 1:
__NOTOC__
Attaches a camera to the bone specified.


==Syntax==
== Syntax ==
<syntaxhighlight lang="javascript">camera.attachToPedBone(ped, boneIndex, x, y, z, heading);</syntaxhighlight>
<pre>
=== Required Arguments ===
camera.attachToPedBone(ped, boneIndex, x, y, z, heading);
</pre>
 
=== Parameters ===
*'''ped:''' Ped handle or object
*'''ped:''' Ped handle or object
*'''boneIndex:''' int
*'''boneIndex:''' {{RageType|Int}} ([[Bones|Bone IDs]])
*'''x:''' float
*'''x:''' {{RageType|Float}}
*'''y:''' float
*'''y:''' {{RageType|Float}}
*'''z:''' float
*'''z:''' {{RageType|Float}}
*'''heading:''' Boolean
*'''heading:''' {{RageType|Boolean}}
===Return value===
 
*'''Undefined'''
== Example ==
==Example==
This creates a camera and then sets it active and attaches it to the player's hand so it stays focused. The camera will not move with the character.
<syntaxhighlight lang="javascript">
 
// todo
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
</syntaxhighlight>
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
==See also==
<pre>
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);
});
</pre>
</div>
 
== See also ==
{{Camera_definition_c}}
{{Camera_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]
[[Category:Camera API]]

Revision as of 12:59, 29 September 2018

Attaches a camera to the bone specified.

Syntax

camera.attachToPedBone(ped, boneIndex, x, y, z, heading);

Parameters

  • ped: Ped handle or object
  • boneIndex: Int (Bone IDs)
  • x: Float
  • y: Float
  • z: Float
  • heading: Boolean

Example

This creates a camera and then sets it active and attaches it to the player's hand so it stays focused. The camera will not move with the character.

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