Cluster Creator Kit Script Reference
    Preparing search index...

    Interface CameraHandlePlayer

    The handle to control the player's camera movement. You can access the handle with PlayerScript.cameraHandle.

    interface CameraHandle {
        calculateDefaultPosition(
            rotation: Quaternion,
            isFirstPersonView: boolean,
        ): Vector3;
        getPosition(): Vector3;
        getRotation(): Quaternion;
        isFirstPersonView(): boolean;
        setFieldOfView(value: number | null, immediate: boolean): void;
        setPerspectiveSwitchingLocked(isLocked: boolean): void;
        setPosition(position: Vector3 | null): void;
        setRotation(rotation: Quaternion | null): void;
        setThirdPersonAvatarForwardLock(value: boolean | null): void;
        setThirdPersonAvatarScreenPosition(
            pos: Vector2 | null,
            immediate: boolean,
        ): void;
        setThirdPersonDistance(distance: number | null, immediate: boolean): void;
        switchToFirstPersonView(): void;
        switchToThirdPersonView(): void;
    }
    Index

    Methods

    • Calculates the camera position as if camera posture is not operated with setPosition() and setRotation().

      In VR environment, it ignores rotation and isFirstPersonView values, returning the same value as getPosition(). In non-VR environment, it calculates the camera position based on the view state specified by rotation and isFirstPersonView.

      Parameters

      • rotation: Quaternion

        The global rotation of the camera, ignoring the roll angle.

      • isFirstPersonView: boolean

        true for first person view, false for third person view.

      Returns Vector3

    • Obtains the current position of the camera in global coordinates. In VR environment, the result indicates the player's eye position. In non-VR environment, the result indicates the camera position based on the current perspective.

      When the player is in non-VR environment and editing accessories, this method returns the camera position that will be applied after the acccessory edit is finished.

      Returns Vector3

    • Obtains the current rotation of the camera in global coordinates. In VR environment, the result indicates the player's eye position. In non-VR environment, the result indicates the camera rotation based on the current perspective.

      When the player is in non-VR environment and editing accessories, this method returns the camera rotation that will be applied after the acccessory edit is finished.

      Returns Quaternion

    • Gets whether the player is using first person view.

      This methods always returns true for the player in VR. When the player is not in VR environment, returns true if the player is using first person view and returns false otherwise.

      This methods will returns a valid value even if camera is in specific modes. You can validate the current camera by calling CameraHandle.getPosition or CameraHandle.getRotation and check the result is not null.

      Returns boolean

      Whether the player is using first person view.

    • Sets the default value of the field of view for players who are not in VR environment. The field of view is specified as the vertical angle from the bottom to the top of the screen.

      This method has no effect in VR. After changing the field of view by this method, the player can still zoom in and out, and switch between first and third person perspectives using zoom.

      The value specified in this method will be reset when calling the method with value is null, or when the validity period of the Player Script expires.

      Parameters

      • value: number | null

        The default value of the field of view in degrees, between 10 and 80. The outsided value will be clamped.

      • immediate: boolean

        If true, the value is applied immediately without interpolation. This parameter is optional, and if omitted, it is treated as false.

      Returns void

    • Locks switching between first-person and third-person views via HUD and zoom in/out.

      This function can be called while the player is in VR, but it does not affect behavior in VR. Even while switching is locked by this function, the script can still change the camera position and the view. When the validity period of the Player Script expires, switching via the HUD and zoom in/out becomes available again.

      Parameters

      • isLocked: boolean

        Whether to lock switching

      Returns void

    • Specifies the camera position in global coordinates.

      The behavior when this method is called is as follows

      • In VR environment
        • It does not affect the camera position in VR environment
      • In non-VR environment
        • If first person view was active just before this method is called, it switches to the third person view camera
        • The specified camera position is reflected
        • Disables the switching operation between first person and third person views
        • The avatar's head always faces the direction of movement unless the camera mode's "Look at camera" is on
        • The rendering quality of the avatar changes depending on the distance from the specified camera position
          • However, the quality of the avatar's motion and audio may decrease significantly when far from the player
        • The following aspects are the same as in the usual third person view
          • Avatar movement controls
          • The source of the player's voice
          • The way sounds are heard
          • Item selection methods
      • In other special modes (such as when editing accessories)
        • The camera position can be specified, but it is not reflected immediately and is reflected after the special mode ends

      The values specified by this method will reset when called with null for position or when the Player Script ends. After reset, the switching operation between first person and third person views will be enabled again. Additionally, if the view was in first person before calling this method, it will return to first person after the reset.

      Parameters

      • position: Vector3 | null

        The global coordinates of the camera.

      Returns void

    • Specifies the camera rotation in global coordinates.

      The behavior when this method is called is as follows

      • In VR environment
        • It does not affect the camera rotation in VR environment
      • In non-VR environment, first person view
        • The specified camera rotation is reflected
        • Disables camera rotation through mouse dragging
        • Does not affect the camera rotation
      • In non-VR environment, third person view
        • The specified camera rotation is reflected
        • Disables camera rotation through mouse dragging
        • The camera position is changed according to the camera rotation and the player's position
      • In other special modes (such as when editing accessories)
        • The camera rotation can be specified, but it is not reflected immediately and is reflected after the special mode ends

      When this method is called with null for rotation or when the Player Script ends, the player will be able to manipulate the camera rotation again. At this point, the camera rotation will be reset to what it was last specified in setRotation(), excluding the roll angle.

      Parameters

      • rotation: Quaternion | null

        The global rotation of the camera.

      Returns void

    • In third-person view, sets whether to fix the avatar's orientation so that it faces forward. This method can be used for the case that the avatar should aim to objects in the world in third-person view.

      This function can also be executed when the player is in a VR environment or first-person view, but it does not affect behavior in a VR environment or first-person view.

      The value specified in this method will be reset when calling the method with value is null, or when the validity period of the Player Script expires.

      Parameters

      • value: boolean | null

        Whether to fix the avatar's orientation to face forward

      Returns void

    • In third-person view, specifies the position on the screen near the avatar's head in screen coordinates. The left edge of the screen corresponds to x=0, and the right edge corresponds to x=1. The bottom edge of the screen corresponds to y=0, and the top edge corresponds to y=1.

      This function can be executed when the player is in a VR environment or in first-person view, but it does not affect behavior in a VR environment or in first-person view.

      The value specified in this method will be reset when calling the method with pos is null, or when the validity period of the Player Script expires.

      Parameters

      • pos: Vector2 | null

        The position on the screen near the avatar's head. Both x and y components are clamped between 0 and 1.

      • immediate: boolean

        If true, the interpolation is skipped and the value is applied immediately. This value is optional and is treated as false if omitted.

      Returns void

    • Specifies the maximum distance between the avatar and the camera in third-person view in meters.

      The actual distance between the camera and the avatar may not be equal to the specified value. If there are walls or ceilings around the avatar, the camera will be closer than the specified distance.

      This function can be executed even when the player is in a VR environment or in first-person view, but it does not affect the behavior in a VR environment or in first-person view.

      The value specified in this method will be reset when calling the method with distance is null, or when the validity period of the Player Script expires.

      Parameters

      • distance: number | null

        The maximum distance between the avatar and the camera. The minimum value is 0.2, and smaller value will be treated same as 0.2.

      • immediate: boolean

        If true, the interpolation is skipped and the value is applied immediately. This value is optional and is treated as false if omitted.

      Returns void

    • Switches to first-person view.

      This function can be called while the player is in VR or already in first-person view, but it has no effect in VR or when the player is in first-person view. Also, if the camera position has been specified with CameraHandle.setPosition, calling this function does not change the perspective.

      Returns void

    • Switches to third-person view.

      This function can be called while the player is in VR or already in third-person view, but it has no effect in VR or when the player is in third-person view. Also, if the camera position has been specified with CameraHandle.setPosition, calling this function does not change the perspective.

      Returns void