Camera::attachToPedBone

From RAGE Multiplayer Wiki
Jump to navigation Jump to search

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