• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Globals

    FirstPersonCamera

    FirstPersonCamera is a built-in client-side camera script that provides first-person perspective gameplay. This script automatically tracks the local player's character and updates the camera position every frame to follow the player at a configured height offset. The camera supports touch and mouse input for rotation with configurable sensitivity, smoothing, and rotation limits (pitch/yaw). Input events (PinchOrDragBegan, PinchOrDragChanged, PinchOrDragEnded) are automatically connected to handle camera rotation. To add this camera to your scene: Right Click in Hierarchy > Highrise > Cameras > FirstPersonCamera

    Configurable Parameters (via Unity Inspector):

    • cameraHeightFromPlayer: Height offset of the camera from player position in world units (default: 1.5, typical eye height)
    • EnableMaxPitch: Whether to limit vertical rotation/looking up and down (default: true)
    • EnableMaxYaw: Whether to limit horizontal rotation/looking left and right (default: false, allows full 360° rotation)
    • minPitch: Minimum pitch angle in degrees - negative values look UP (default: -45, allows looking up 45°)
    • maxPitch: Maximum pitch angle in degrees - positive values look DOWN (default: 45, allows looking down 45°)
    • minYaw: Minimum yaw angle in degrees for left rotation (default: -360 for full rotation)
    • maxYaw: Maximum yaw angle in degrees for right rotation (default: 360 for full rotation)
    • touchRotationSensitivity: How fast the camera rotates from touch input - higher = faster (default: 0.4, range 0.1-1.0 recommended)
    • mouseRotationSensitivity: How fast the camera rotates from mouse input - higher = faster (default: 0.25, range 0.1-0.5 recommended)
    • rotationSmoothing: Smoothing applied per frame - 1 = full smoothing, 0 = instant/no smoothing (default: 1)
    • FOV: Field of view in degrees - higher = wider view, lower = zoomed in (default: 70, typical range 60-90 for FPS)

    How It Works:

    • On Start: Initializes camera rotation and detects appropriate sensitivity for touch vs mouse input
    • Automatically tracks when the local player's character spawns or changes
    • Every frame in Update: Positions camera at player's eye level (player position + height offset) and applies rotation
    • Input handling: Touch/mouse drag rotates the camera, with movement converted to rotation angles based on sensitivity
    • Rotation terminology: Pitch = vertical rotation (looking up/down), Yaw = horizontal rotation (looking left/right)
    • Rotation limits: When enabled, clamps how far you can look up/down or left/right

    Methods

    OnLocalCharacter

    ClientOnly
    NoSelfParameter

    Internal function called when the local player's character spawns or changes. Sets up the camera to follow the character.

    Parameters

    player
    character

    Returns

    void

    Rotate

    ClientOnly
    NoSelfParameter

    Internal function that applies rotation to the camera with sensitivity and smoothing. Updates pitch (vertical looking up/down) and yaw (horizontal looking left/right), clamping to configured limits if enabled.

    Parameters

    rotate

    Returns

    void

    RotateCamera

    ClientOnly
    NoSelfParameter

    Internal function that processes touch/mouse drag input to rotate the camera. Converts screen movement (in pixels) to rotation angles, applies sensitivity, and updates both horizontal and vertical rotation.

    Parameters

    Returns

    void

    SetFirstPersonView

    ClientOnly
    NoSelfParameter

    Internal function that positions the camera at the target position plus the configured height offset (cameraHeightFromPlayer in world units).

    Parameters

    target

    Returns

    void

    UpdatePosition

    ClientOnly
    NoSelfParameter

    Internal function called every frame. Positions the camera at the player's eye level (player position + height offset) and applies the current pitch and yaw rotation.

    Returns

    void

    Updated 13 days ago

    PocketWorlds Icon

    © 2025 Pocket Worlds. All rights reserved.