Camera::attachTo: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
(Added example, added description)
Line 1: Line 1:
Attaches your camera to an object.
*JulioNIB:<br>Last param determines if its relative to the Entity
*JulioNIB:<br>Last param determines if its relative to the Entity
==Syntax==
==Syntax==
Line 11: Line 13:
*'''Undefined'''
*'''Undefined'''
==Example==
==Example==
Attaches a camera to a vehicle and sets it as your active camera.
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
let mainCar = mp.vehicles.new(mp.game.joaat("turismor"), new mp.Vector3(-421.88, 1136.86, 326));
 
mp.events.add("vehCam", () => {
    vehicleCamera.attachTo(mainCar.handle, 0, 0, 2.0, false);
    vehicleCamera.setActive(true);
    mp.game.cam.renderScriptCams(true, false, 0, true, false);
});
</syntaxhighlight>
</syntaxhighlight>
</div>
==See also==
==See also==
{{Camera_definition_c}}
{{Camera_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Revision as of 08:34, 17 June 2018

Attaches your camera to an object.

  • JulioNIB:
    Last param determines if its relative to the Entity

Syntax

camera.attachTo(entity, xOffset, yOffset, zOffset, isRelative);

Required Arguments

  • entity: Entity handle or object
  • xOffset: float
  • yOffset: float
  • zOffset: float
  • isRelative: Boolean

Return value

  • Undefined

Example

Attaches a camera to a vehicle and sets it as your active camera.

Client-Side
let mainCar = mp.vehicles.new(mp.game.joaat("turismor"), new mp.Vector3(-421.88, 1136.86, 326));

mp.events.add("vehCam", () => {
    vehicleCamera.attachTo(mainCar.handle, 0, 0, 2.0, false);
    vehicleCamera.setActive(true);
    mp.game.cam.renderScriptCams(true, false, 0, true, false);
});

See also