Table of Contents

Class Basic3DCameraController

Namespace
Stride.CommunityToolkit.Scripts
Assembly
Stride.CommunityToolkit.dll

A script that allows to move and rotate an entity through keyboard, mouse and touch input to provide basic camera navigation.

[Display("Basic 3D Camera Controller", null)]
[ComponentCategory("Camera")]
public class Basic3DCameraController : SyncScript, IIdentifiable, ICollectorHolder
Inheritance
Basic3DCameraController
Implements
Inherited Members
Extension Methods

Remarks

The entity can be moved using W, A, S, D, Q and E, arrow keys, a gamepad's left stick or dragging/scaling using multitouch. Rotation is achieved using the Numpad, the mouse while holding the right mouse button, a gamepad's right stick, or dragging using single-touch.

This functionality is inspired by Stride.Assets.Presentation, Assets->Scripts->Camera

Constructors

Basic3DCameraController()

Initializes a new instance of the Basic3DCameraController class.

public Basic3DCameraController()

Basic3DCameraController(ScreenAnchor?)

Initializes a new instance of the Basic3DCameraController class, optionally moving the shared overlay to an anchor.

public Basic3DCameraController(ScreenAnchor? helpPosition = null)

Parameters

helpPosition ScreenAnchor?

Where the shared DebugOverlay - and so the camera help - is drawn. null, the default, leaves the overlay where it is, so a position set elsewhere (for example before the controller starts) is kept.

Properties

Gamepad

Enables gamepad input when true.

public bool Gamepad { get; set; }

Property Value

bool

HelpCollapsed

Gets or sets whether the camera's help starts collapsed to its title line, leaving a one-line reminder of the key rather than the full list. Defaults to true, and must be set before the script starts.

public bool HelpCollapsed { get; set; }

Property Value

bool

Remarks

Collapsed by default because these keys are the same in every scene and stop being worth ten lines of screen space almost immediately, while whatever the scene itself has to say does not. The remaining line names the key, so nothing is hidden without a way back.

HelpToggleKey

Gets or sets the key that collapses and expands the camera's help. Defaults to F2. Must be set before the script starts.

public Keys HelpToggleKey { get; set; }

Property Value

Keys

KeyboardMovementSpeed

Base translation speed (units/second) for keyboard navigation.

public Vector3 KeyboardMovementSpeed { get; set; }

Property Value

Vector3

KeyboardRotationSpeed

Rotation speed for keyboard / gamepad discrete rotation.

public Vector2 KeyboardRotationSpeed { get; set; }

Property Value

Vector2

MouseRotationSpeed

Sensitivity for mouse-driven yaw/pitch adjustments.

public Vector2 MouseRotationSpeed { get; set; }

Property Value

Vector2

ShowHelp

Gets or sets whether the camera's help is put on the shared DebugOverlay at all. Defaults to true, and must be set before the script starts.

public bool ShowHelp { get; set; }

Property Value

bool

ShowInstructions

Gets or sets whether the camera's help section is shown.

public bool ShowInstructions { get; set; }

Property Value

bool

Remarks

This hides only the camera's own lines. The overlay itself, and anything else contributing to it, is toggled with ToggleKey.

SpeedFactor

Multiplier applied when sprint modifier (shift / pad buttons) is active.

public float SpeedFactor { get; set; }

Property Value

float

TouchMovementSpeed

Translation speed scaling for touch gestures (XY, Z).

public Vector3 TouchMovementSpeed { get; set; }

Property Value

Vector3

TouchRotationSpeed

Sensitivity for touch drag rotation (yaw, pitch).

public Vector2 TouchRotationSpeed { get; set; }

Property Value

Vector2

Methods

Start()

Initializes help overlay, caches default transform, and configures gesture recognizers.

public override void Start()

Update()

Per-frame update: processes input and applies translation/rotation.

public override void Update()