Camera Control

Control camera movement and focus during runtime to track moving objects, create cinematic views, or guide users through your digital twin.

New Feature: CameraFollowObject component is available since realvirtual version 6.0.7.

Overview

realvirtual provides comprehensive camera control capabilities for runtime navigation, object tracking, and preset camera positions. The system is designed for both no-code Inspector configuration and scripting integration, making it accessible to designers while remaining powerful for developers.

📝 Note This section covers runtime camera control features for following objects and loading preset positions. For standard scene navigation with mouse/keyboard during runtime (pan, rotate, zoom, first-person mode), see the main Runtime UI documentation.

Camera Control Options

realvirtual offers three complementary approaches to camera control:

1. Camera Position Presets (CameraPosition Component)Recommended for beginners

  • Save and load complete camera views as reusable preset assets

  • Create camera navigation buttons without any coding

  • Automatic startup position loading

  • Keyboard shortcuts and touch gestures for quick access

  • Perfect for: multi-view dashboards, guided tours, preset navigation

2. Object Following and Focus (CameraFollowObject Component)

  • Track moving objects continuously (follow mode)

  • One-time smooth transitions to view specific objects (focus mode)

  • Auto-calculated distance and angles or custom positioning

  • Optional user control (rotation/zoom) during following

  • Perfect for: AGV tracking, process monitoring, operator attention management

3. Direct Camera Control (SceneMouseNavigation API)

  • Programmatic camera positioning from scripts

  • Advanced integration with automation logic

  • Custom camera sequences and animations

  • Perfect for: automated demonstrations, complex camera movements, custom UI

Common Use Cases

  • Camera Preset Navigation - Quick access to predefined views via buttons, keyboard, or gestures

  • AGV/Mobile Robot Tracking - Follow autonomous vehicles as they navigate through facilities

  • Process Visualization - Focus on specific machines or operations during demonstrations

  • Guided Tours - Create automated camera sequences that highlight key areas

  • Multi-View Dashboards - Provide operators with instant access to different facility areas

  • Operator Training - Direct user attention to important components

  • Remote Monitoring - Track critical moving equipment in real-time

Camera control integrates seamlessly with PLC signals, UI buttons, and scripting, making it suitable for both automated sequences and user-controlled interactions.


Camera Position Presets - No-Code Approach

The CameraPosition component system provides the simplest way to create camera navigation without any coding. It allows you to save complete camera views as reusable preset assets and trigger them via buttons, keyboard shortcuts, or touch gestures.

How It Works

The CameraPosition system consists of two parts:

  1. CameraPos ScriptableObject Assets - Store camera state (position, rotation, distance, orthographic settings)

  2. CameraPosition Component - Load and activate camera presets when triggered

This separation allows you to create a library of camera views that can be reused across different buttons, keyboard shortcuts, and automation triggers.

CameraPosition Inspector showing configuration for camera preset views
Two CameraPosition components configured with different preset views and activation methods

Creating Camera Position Presets

Follow these steps to create and save a camera position preset:

In Edit Mode:

  1. Create the ScriptableObject asset

    • Right-click in Project window → Create > realvirtual > Add Camera Position

    • Name the asset descriptively (e.g., "MainOverview", "RobotStation1", "TopView")

  2. Attach CameraPosition component to Main Camera

    • Select the Main Camera in Hierarchy (/realvirtual/Main Camera)

    • Click Add Component → Search for CameraPosition

  3. Assign the ScriptableObject asset

    • In the CameraPosition component, assign your CameraPos asset to the Campos property

In Play Mode (Game Mode):

  1. Start the simulation

    • Press the Play button to enter Play mode

  2. Position your Game view camera

    • Navigate the camera to your desired view using realvirtual runtime controls:

      • Middle mouse button + drag - Pan camera

      • Right mouse button + drag - Rotate camera around pivot point

      • Mouse scroll wheel - Zoom in/out

  3. Save the current position

    • With the Main Camera still selected, find the CameraPosition component in Inspector

    • Click the "Save current Position" button

    • The CameraPos asset now stores the current Game view camera position

⚠️ Important Camera positions must be saved in Play mode when the Game view camera is active. The "Save current Position" button captures the runtime camera's current position and rotation.

💡 Tip Create multiple CameraPos assets for different areas or views in your digital twin. Build a library of presets like "Overview", "DetailView1", "DetailView2", "TopView", "SideView" for comprehensive navigation.

Adding CameraPosition to Your Scene

Camera position components are typically added to the Main Camera (/realvirtual/Main Camera) to manage different camera views.

Step 1: Add CameraPosition Component to Main Camera

  1. Select the Main Camera in your Hierarchy (/realvirtual/Main Camera)

  2. Click Add Component in the Inspector

  3. Search for and add CameraPosition

  4. Assign your CameraPos asset to the Campos property

  5. Configure activation settings (keyboard shortcut, activate on start, etc.)

Step 2: Add Multiple CameraPosition Components (Optional)

You can add multiple CameraPosition components to the Main Camera, each configured for a different view:

  1. Add another CameraPosition component to the same Main Camera

  2. Assign a different CameraPos asset (e.g., "TopView", "DetailView")

  3. Set a different Key Code (e.g., F1 for first view, F2 for second view)

  4. Repeat for additional preset views

Step 3: Connect to UI Buttons (Optional)

For button-based navigation:

  1. Select your UI button GameObject

  2. In the Button component's OnClick event list, click +

  3. Drag the Main Camera GameObject to the object field

  4. Select CameraPosition > SetCameraPosition() from the function dropdown

  5. If you have multiple CameraPosition components on the Main Camera, select the specific one you want to trigger

CameraPosition Properties

Basic Configuration

Name (string) - Display name for this camera position. Shows in runtime UI and can be used for identification. Default: "Main Camera"

Campos (CameraPos asset) - The camera position preset asset to load. This ScriptableObject contains the saved camera state (position, rotation, distance, orthographic settings). Assign the CameraPos asset you created earlier.

Activation Methods

View Name (string) - Optional identifier for this view. Can be used for scripting lookups or display purposes. Example: "View1", "Overview", "DetailStation"

Key Code (KeyCode) - Keyboard shortcut to activate this camera position. Press this key during runtime to instantly load the preset view. Examples:

  • F1, F2, F3 - Function keys for quick view switching

  • Alpha1, Alpha2 - Number keys for numbered views

  • None - Disable keyboard activation

Activate On Start (boolean) - When enabled, this camera position automatically loads when Play mode starts or when the component is enabled. Use this for your default startup view.

⚠️ Warning Only enable Activate On Start on ONE CameraPosition component. Multiple components with this setting enabled will conflict.

Double Tap Gesture (Touch Interaction) - Configure touch gesture activation for mobile or touchscreen interfaces:

  • None - Disable touch gesture activation

  • Touch Interaction GameObject - Assign the touch interaction component that manages gestures

  • When assigned and user performs double-tap gesture, this camera position activates

This enables touchscreen users to quickly navigate between views using familiar double-tap gestures.

Inspector Buttons

The CameraPosition component provides two convenient buttons in the Inspector:

  • Save current Position - Captures the current Scene view camera state and updates the assigned CameraPos asset

  • Set Camera to saved Position - Loads the camera view from the assigned CameraPos asset

These buttons work in both Edit mode and Play mode, allowing you to test and refine camera positions during development.

💡 Workflow Tip Use "Save current Position" to quickly update presets as you refine your views. Navigate to the desired position in Scene view, then click the button to update the asset without leaving the Inspector.

Common Setup Patterns

Pattern 1: UI Button Navigation (No Coding)

Create a navigation panel with buttons for different views:

  1. Create 3-5 CameraPos assets for different areas (Overview, Station1, Station2, etc.)

  2. Select Main Camera and add 3-5 CameraPosition components (one for each view)

  3. Assign different CameraPos assets to each CameraPosition component

  4. Add UI buttons to your Canvas

  5. Connect each button's OnClick event to Main Camera > CameraPosition > SetCameraPosition()

  6. Select the specific CameraPosition component for each button

Result: Users click buttons to instantly navigate between predefined views.

Pattern 2: Keyboard Shortcuts

Provide power users with keyboard shortcuts:

  1. Select the Main Camera in Hierarchy

  2. Add multiple CameraPosition components to the Main Camera

  3. Assign different CameraPos assets to each component

  4. Set different KeyCodes (F1, F2, F3, etc.) for each CameraPosition

  5. Set Active to "PlayModeOnly" on all components

Result: Press F1-F5 to instantly switch between 5 preset views.

Pattern 3: Automatic Startup View

Set a default camera position when the scene starts:

  1. Select your Main Camera in Hierarchy

  2. On the SceneMouseNavigation component, configure camera position settings:

    • Last Camera Position - Assign your default startup view CameraPos asset

    • Set Camera Pos On Start Play - Enable to load this position at startup

    • Save Camera Pos On Quit - Enable to save current camera state when exiting Play mode

    • Set Editor Camera Pos - Enable to sync Scene view with saved position

    • Interpolate To New Camerapoitions - Enable for smooth camera transitions

SceneMouseNavigation camera position settings
SceneMouseNavigation component on Main Camera showing camera position startup settings

⚠️ Important: Save Camera Pos On Quit Enable Save Camera Pos On Quit temporarily when you want to capture your final camera position. Once you've set your permanent startup position, disable this setting to prevent it from overwriting your preset every time you exit Play mode. Leave it enabled only if you want the camera position to dynamically update between sessions.

Result: Scene always starts from the same professional overview position.

Pattern 4: Combined Approach

Combine all methods for maximum flexibility:

  1. Configure startup position on SceneMouseNavigation (Pattern 3)

  2. Add UI buttons for common views (Pattern 1)

  3. Add keyboard shortcuts for power users (Pattern 2)

  4. Optional: Add double-tap gestures for mobile (configure Touch Interaction)

Result: Complete navigation system supporting multiple user preferences and devices.

⚠️ Important: Avoiding Conflicts Between Camera Systems

When combining multiple camera control approaches (CameraPosition, CameraFollowObject, and SceneMouseNavigation settings), be careful to avoid conflicts:

  • Only ONE "Activate On Start": Enable "Activate On Start" on only ONE CameraPosition component. Multiple components with this enabled will conflict.

  • Don't set positions in parallel: Avoid triggering multiple camera position changes at the same time (e.g., starting follow mode while a camera position is animating).

  • SceneMouseNavigation vs CameraPosition startup: If using CameraPosition with "Activate On Start", disable "Set Camera Pos On Start Play" on SceneMouseNavigation to avoid both systems trying to set the startup position.

  • Following mode takes priority: When CameraFollowObject is actively following an object, camera position changes are blocked until following stops.

  • Sequential transitions: If you need to combine different camera movements (e.g., load position, then start following), use scripting or Events to trigger them sequentially with proper delays.

Camera Position vs CameraFollowObject

Use CameraPosition when:

  • You want predefined static camera views

  • Creating navigation between fixed viewpoints (e.g., different areas of a factory)

  • Setting up startup camera position

  • Building multi-view dashboards

  • No coding required

Use CameraFollowObject when:

  • You need to track moving objects (AGVs, robots, conveyors)

  • Creating dynamic camera that follows motion

  • Focusing attention on specific components during demonstrations

  • Combining following with user control (rotation/zoom during tracking)

Both systems can be used together in the same scene for comprehensive camera control.


CameraFollowObject Component

The CameraFollowObject component controls camera behavior for both continuous following and one-time focus operations. Unlike CameraPosition which loads static preset views, CameraFollowObject creates dynamic camera behavior that tracks moving objects in real-time or smoothly transitions to focus on specific components.

CameraFollowObject Inspector with follow settings
CameraFollowObject component configured to follow a robot TCP with rotation and zoom control enabled

Adding CameraFollowObject

  1. Add the component to any GameObject in your scene (commonly attached to UI buttons)

  2. Assign the Object To Follow property to your target GameObject

  3. Configure distance and angle settings as needed

  4. Connect to buttons or PLC signals for triggering

Properties

Target Object

Object To Follow (GameObject) - The GameObject to track or focus on. This can be any object in your scene including MUs, robots, conveyors, or machine components. The camera will automatically calculate the object's bounding box center from all child renderers.

Camera Distance

Use Custom Distance (boolean) - Controls whether to use a manually specified distance or auto-calculate the optimal viewing distance. When disabled, the camera automatically calculates the distance needed to fit the object at approximately 1/3 of screen space, providing a comfortable viewing size that shows the object clearly without filling the entire frame.

Distance (float, meters) - Camera distance from the object center when Use Custom Distance is enabled. Adjust this value to control how close or far the camera appears from the target. Typical values range from 2 meters for small objects to 20 meters for large equipment.

Camera Angle

Use Custom View Angle (boolean) - Controls whether to use a manually specified camera rotation or auto-select the optimal angle. When disabled for FocusOnObject, the camera calculates an optimal viewpoint slightly above and to the side of the object. When disabled for StartFollowing, the current camera angle is maintained.

View Angle (Vector3, degrees) - Camera rotation in Euler angles (X, Y, Z) when Use Custom View Angle is enabled. Use this to set precise camera orientations such as top view (90, 0, 0) or side view (0, 90, 0).

User Control Options

Allow Rotation (boolean) - When enabled during following mode, users can orbit the camera around the object using mouse or touch input while the object remains centered. This is useful for inspection scenarios where operators need to examine moving equipment from different angles.

Allow Zoom (boolean) - When enabled during following mode, users can adjust the camera distance from the object using scroll wheel or pinch gestures while maintaining focus on the target. Combine with Allow Rotation for full user control during tracking.

Smoothness

Lerp Speed (float, 0.1-10.0) - Controls camera tracking smoothness during following mode. Lower values (0.1-0.5) create smooth cinematic motion, medium values (0.5-2.0) provide balanced tracking, and higher values (2.0-10.0) create tight, responsive tracking. Default: 1.0

Smooth Start (boolean) - When enabled, the camera smoothly transitions to the object when starting to follow. When disabled, the camera jumps immediately to the following position. Enable for professional presentations, disable for instant response in monitoring scenarios.

Stop Button UI

Show Stop Button (boolean) - When enabled, displays a UI button during camera follow mode that allows users to stop the camera tracking. The button appears automatically when following starts and disappears when following stops. This provides users with a clear, visible way to exit follow mode without requiring keyboard shortcuts or external buttons.

Stop Camera Focus button appears during following mode
The "Stop Camera Focus" button automatically appears during camera follow mode when Show Stop Button is enabled

Stop Button Prefab (GameObject) - Optional custom prefab for the stop button UI. If null, uses the default rvUICameraFocusButton prefab from Resources. Assign a custom prefab here if you want to customize the button's appearance, position, or text. The custom prefab must have an rvUICameraFocusButton component.

Stop On Mouse Click (boolean) - When enabled, following stops automatically if the user clicks any mouse button. This provides an alternative way to exit follow mode by simply clicking anywhere in the viewport.

Follow Mode

Auto Start Following (boolean) - Automatically begins following the target object when the scene starts or when the component is enabled. Enable this for scenarios where tracking should start immediately, such as startup demonstrations or monitoring views.

PLC Signal Control

PLC Signal Start Following (PLCInputBool) - PLC signal that controls following mode. When the signal transitions to true, following begins. When the signal returns to false, following stops automatically. Use this for automated sequences controlled by your PLC logic.

Follow Active (boolean) - Public boolean property that can be controlled externally by scripts or PLCOutputBool components. Set to true to start following, false to stop. This provides an alternative to PLC signals for scripting scenarios or UI toggle buttons.

💡 Hint PLC signal monitoring uses FixedUpdate timing to ensure synchronization with PLC communication cycles. Either the PLC signal or Follow Active bool can trigger following - both do not need to be true simultaneously.

Control Methods

The CameraFollowObject component provides three main methods that can be triggered from UI buttons, scripts, or other events:

StartFollowing()

Begins continuous camera tracking of the target object. The camera will smoothly move to the configured viewing position and then continuously update its position to keep the object centered as it moves. Following continues until explicitly stopped by calling StopFollowing() or by setting control signals to false.

Use Cases:

  • Track AGVs moving through warehouses

  • Follow robotic arms during operation sequences

  • Monitor conveyor transport of critical products

  • Automated camera sequences in demonstrations

Button Setup: Add a button to your UI and connect its OnClick event to CameraFollowObject.StartFollowing(). For toggle behavior, use ToggleFollowing() instead.

StopFollowing()

Ends continuous camera tracking and returns the camera to normal user-controlled navigation mode. The camera remains at its current position and rotation, allowing users to navigate freely.

Use Cases:

  • End automated tracking sequences

  • Return control to operators

  • Switch between tracked objects

FocusOnObject()

Performs a one-time smooth camera movement to view the target object without continuous tracking. The camera will interpolate to the optimal viewing position, but will not continue following if the object moves afterward. This is ideal for guided tours or drawing attention to specific components.

Use Cases:

  • Highlight specific machines during presentations

  • Create waypoint-based guided tours

  • Quick navigation to specific areas

  • Operator attention management in training scenarios

ToggleFollowing()

Switches between following and not following states. If currently following, this method stops tracking. If not following, it starts tracking. Useful for toggle buttons in your UI.

Inspector Buttons

The component provides three buttons directly in the Inspector for testing during development:

  • Start Following - Test continuous tracking

  • Stop Following - End tracking

  • Focus On Object - Test one-time focus

These buttons work in both Edit mode and Play mode, allowing you to preview camera behavior during scene setup.

Distance and Angle Auto-Calculation

When custom distance or angle options are disabled, the camera uses intelligent auto-calculation:

Auto Distance Calculation:

  • Analyzes all renderers on the target object and its children

  • Calculates combined bounding box dimensions

  • Determines distance to fit object at 1/3 screen space

  • Adds safety margin based on object size

  • Ensures object is clearly visible without being too close or far

Auto Angle Calculation:

  • FocusOnObject: Calculates optimal viewpoint slightly elevated and offset from object center for best visibility

  • StartFollowing: Maintains current camera angle to avoid disorienting users during tracking

💡 Hint Auto-calculation works best with objects that have MeshRenderer or SkinnedMeshRenderer components. For objects without renderers, the camera uses the object's transform position and a default distance of 5 meters.


Setting Camera Positions via Code

For advanced scenarios, you can control camera positions programmatically using the SceneMouseNavigation public API. This is useful for creating custom camera sequences, automation logic, or dynamic camera movements based on simulation events.

Accessing SceneMouseNavigation

The SceneMouseNavigation component is located on the Main Camera. There are several ways to get a reference to it:

Method 1: FindObjectOfType (Recommended - Simple and Reliable)

using realvirtual;

// Find the SceneMouseNavigation component in the scene
SceneMouseNavigation sceneNav = FindObjectOfType<SceneMouseNavigation>();

Method 2: Via Main Camera GameObject

using realvirtual;

// Get reference via specific GameObject path
GameObject mainCamera = GameObject.Find("/realvirtual/Main Camera");
SceneMouseNavigation sceneNav = mainCamera.GetComponent<SceneMouseNavigation>();

Method 3: Using Camera.main

using realvirtual;

// Get reference via Unity's main camera
SceneMouseNavigation sceneNav = Camera.main.GetComponent<SceneMouseNavigation>();

💡 Tip Use FindObjectOfType<SceneMouseNavigation>() for the simplest and most reliable approach. It works regardless of the camera's exact hierarchy path.

SetNewCameraPosition Method

The primary method for programmatic camera control:

public void SetNewCameraPosition(Vector3 targetPos, float camDistance, Vector3 camRotation, bool noInterpolate = false)

Parameters:

  • targetPos (Vector3) - The world position the camera looks at (orbit center point)

  • camDistance (float) - Distance from target to camera in meters

  • camRotation (Vector3) - Camera rotation as Euler angles (X, Y, Z) in degrees

  • noInterpolate (bool) - If true, jump immediately; if false, smoothly interpolate to position (default: false)

Example - Move Camera to Specific Position:

using UnityEngine;
using realvirtual;

public class CameraController : MonoBehaviour
{
    private SceneMouseNavigation sceneNav;

    void Start()
    {
        // Get SceneMouseNavigation reference
        sceneNav = FindObjectOfType<SceneMouseNavigation>();
    }

    public void MoveCameraToStation1()
    {
        // Define target position, distance, and rotation
        Vector3 targetPosition = new Vector3(10f, 0f, 5f);  // Look at point
        float distance = 8f;                                 // 8 meters from target
        Vector3 rotation = new Vector3(30f, 45f, 0f);       // Camera angle

        // Move camera with smooth interpolation
        sceneNav.SetNewCameraPosition(targetPosition, distance, rotation, noInterpolate: false);
    }

    public void JumpCameraToOverview()
    {
        // Jump instantly without interpolation
        Vector3 targetPosition = new Vector3(0f, 0f, 0f);
        float distance = 15f;
        Vector3 rotation = new Vector3(45f, 90f, 0f);

        sceneNav.SetNewCameraPosition(targetPosition, distance, rotation, noInterpolate: true);
    }
}

Example - Camera Sequence with Coroutines:

using System.Collections;
using UnityEngine;
using realvirtual;

public class CameraTour : MonoBehaviour
{
    private SceneMouseNavigation sceneNav;

    void Start()
    {
        GameObject mainCamera = GameObject.Find("/realvirtual/Main Camera");
        sceneNav = mainCamera.GetComponent<SceneMouseNavigation>();
    }

    public void StartTour()
    {
        StartCoroutine(CameraTourSequence());
    }

    IEnumerator CameraTourSequence()
    {
        // Position 1: Overview
        sceneNav.SetNewCameraPosition(new Vector3(0, 0, 0), 20f, new Vector3(45, 0, 0));
        yield return new WaitForSeconds(3f);

        // Position 2: Station A
        sceneNav.SetNewCameraPosition(new Vector3(10, 0, 5), 8f, new Vector3(30, 45, 0));
        yield return new WaitForSeconds(3f);

        // Position 3: Station B
        sceneNav.SetNewCameraPosition(new Vector3(-10, 0, -5), 8f, new Vector3(30, -45, 0));
        yield return new WaitForSeconds(3f);
    }
}

Using with CameraPos Assets

You can also load CameraPos assets programmatically:

using UnityEngine;
using realvirtual;

public class LoadCameraPreset : MonoBehaviour
{
    public CameraPos overviewPosition;  // Assign in Inspector
    private SceneMouseNavigation sceneNav;

    void Start()
    {
        GameObject mainCamera = GameObject.Find("/realvirtual/Main Camera");
        sceneNav = mainCamera.GetComponent<SceneMouseNavigation>();
    }

    public void LoadPreset()
    {
        if (overviewPosition != null)
        {
            sceneNav.SetNewCameraPosition(
                overviewPosition.TargetPosition,
                overviewPosition.Distance,
                overviewPosition.Rotation,
                noInterpolate: false
            );
        }
    }
}

Interpolation Control

Control smooth camera transitions using the SceneMouseNavigation properties:

  • InterpolateToNewCamerapoitions (bool) - Enable/disable smooth interpolation

  • CameraInterpolationSpeed (float) - Speed of camera transitions (default: 0.1)

// Disable interpolation for instant jumps
sceneNav.InterpolateToNewCamerapoitions = false;
sceneNav.SetNewCameraPosition(targetPos, distance, rotation);

// Re-enable with custom speed
sceneNav.InterpolateToNewCamerapoitions = true;
sceneNav.CameraInterpolationSpeed = 0.05f;  // Slower transitions
sceneNav.SetNewCameraPosition(targetPos, distance, rotation);

Following Objects Programmatically

For continuous object tracking via code, use the StartFollowing method in SceneMouseNavigation:

public void StartFollowing(GameObject targetObject, float? distance = null, Vector3? viewAngle = null,
    bool allowRotation = false, bool allowZoom = false, float lerpSpeed = 1.0f,
    bool smoothStart = true, bool stopOnMouseClick = false)

Parameters:

  • targetObject (GameObject) - The object to follow

  • distance (float?, optional) - Camera distance in meters. If null, auto-calculates based on object bounds

  • viewAngle (Vector3?, optional) - Camera rotation in Euler angles. If null, uses current angle (StartFollowing) or optimal angle (FocusOnObject)

  • allowRotation (bool) - If true, user can orbit camera while following

  • allowZoom (bool) - If true, user can zoom in/out while following

  • lerpSpeed (float) - Smoothness factor (0.1 = cinematic, 10.0 = instant)

  • smoothStart (bool) - If true, smoothly transitions to object. If false, jumps immediately

  • stopOnMouseClick (bool) - If true, stops following when user clicks any mouse button

Example - Follow Moving AGV:

using UnityEngine;
using realvirtual;

public class AGVTracker : MonoBehaviour
{
    public GameObject agv;
    private SceneMouseNavigation sceneNav;

    void Start()
    {
        sceneNav = FindObjectOfType<SceneMouseNavigation>();
    }

    public void StartTrackingAGV()
    {
        // Follow AGV with auto-calculated distance, allowing user rotation and zoom
        sceneNav.StartFollowing(
            targetObject: agv,
            distance: null,              // Auto-calculate optimal distance
            viewAngle: null,             // Maintain current camera angle
            allowRotation: true,         // User can orbit around AGV
            allowZoom: true,             // User can zoom in/out
            lerpSpeed: 0.3f,            // Smooth cinematic tracking
            smoothStart: true,           // Smooth transition to AGV
            stopOnMouseClick: false      // Continue following even if user clicks
        );
    }

    public void StopTracking()
    {
        sceneNav.StopFollowing();
    }
}

Example - Focus on Machine with Custom Settings:

public void FocusMachineOnError(GameObject machine)
{
    SceneMouseNavigation sceneNav = FindObjectOfType<SceneMouseNavigation>();

    // Focus on machine with specific distance and angle
    sceneNav.FocusOnObject(
        machine,
        distance: 8f,                    // 8 meters from machine
        viewAngle: new Vector3(30, 45, 0) // View from 30° up, 45° around
    );
}

💡 Tip For button-triggered following, use the CameraFollowObject component which provides Inspector configuration without coding. For dynamic code-based tracking (e.g., follow different objects based on events), use SceneMouseNavigation.StartFollowing() directly.


© 2025 realvirtual GmbH https://realvirtual.io - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.

Last updated