Camera::attachToPedBone: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
m (Replaced HTML with template)
 
Line 18: Line 18:
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.
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.


<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>
<pre>
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 32: Line 31:
});
});
</pre>
</pre>
</div>
}}


== See also ==
== See also ==

Latest revision as of 13:17, 26 October 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.attachToPedBone(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