Load camera configuration||doc135747

September 20, 2022

Format

 GameSettings:loadCameraCfg(config) 

Description

Load camera configuration.


Precautions

  • In the default first-person perspective, the client will not be able to see its own character model, so it is recommended not to modify the camera configuration of the first-person perspective. If you do not need the first-person perspective, you can set it in the editor as non-switchable or in the client code. in the settings.

Parameters

Variable name type Description
config table Camera configuration, which defines the camera angles that the game can switch to

Camera configuration content

Field Name type Defaults Description
canSwitchView boolean true Is it possible to switch the viewing angle
viewModeConfig table The default presence of perspective information is determined by the editor's game settings An array of up to five camera perspective information can exist

View information configuration

An ordered table array, the position of the view information in the table determines the configuration of the first view

name type Defaults Description
enable boolean true Is it possible to switch to this perspective
enableCollisionDetect boolean true Whether to advance the camera when blocks block the view
viewFovAngle int true Wide angle of view
lockBodyRotation boolean true Whether the main player body rotates with the camera
lockViewPos boolean false Whether to lock the camera position
lockSlideScreen boolean false Whether to lock the sliding screen to rotate the camera
distance float 4 camera distance
pos Vector3 {x=0, y=0, z=0} Coordinate point when the camera position is locked
liftMinHeight float 0 When the jump height reaches a certain level, the viewing angle will be raised


Code Samples

Reload the camera perspective of the game, so that the game has only two perspectives, one is to follow the player, and the other is to lock the camera coordinates at the coordinates (10,10,10)

Lib.subscribeEvent(Event.EVENT_FINISH_DEAL_GAME_INFO, function() -- Register the callback function when the client game is initialized
 local modeCfg = {}[
 local cameraCfg = {canSwitch = true, viewModeConfig = modeCfg}
 modeCfg[1] = {} -- Keep the default value without changing any information from the first perspective
 modeCfg[2] = {lockViewPos = true, pos = Lib.v3(10,10,10), lockBodyRotation = false}
 Blockman.Instance().gameSettings:loadCameraCfg (cameraCfg)
end)