Table of Contents

Class XRPositionalTracker

Namespace
Godot
Assembly
GodotSharp.dll

An instance of this object represents a device that is tracked, such as a controller or anchor point. HMDs aren't represented here as they are handled internally.

As controllers are turned on and the XRInterface detects them, instances of this object are automatically added to this list of active tracking objects accessible through the XRServer.

The XRController3D and XRAnchor3D both consume objects of this type and should be used in your project. The positional trackers are just under-the-hood objects that make this all work. These are mostly exposed so that GDExtension-based interfaces can interact with them.

public class XRPositionalTracker : RefCounted, IDisposable
Inheritance
XRPositionalTracker
Implements
Inherited Members

Constructors

XRPositionalTracker()

public XRPositionalTracker()

Properties

Description

The description of this tracker.

public string Description { get; set; }

Property Value

string

Hand

Defines which hand this tracker relates to.

public XRPositionalTracker.TrackerHand Hand { get; set; }

Property Value

XRPositionalTracker.TrackerHand

Name

The unique name of this tracker. The trackers that are available differ between various XR runtimes and can often be configured by the user. Godot maintains a number of reserved names that it expects the XRInterface to implement if applicable:

- left_hand identifies the controller held in the players left hand

- right_hand identifies the controller held in the players right hand

public StringName Name { get; set; }

Property Value

StringName

Profile

The profile associated with this tracker, interface dependent but will indicate the type of controller being tracked.

public string Profile { get; set; }

Property Value

string

Type

The type of tracker.

public XRServer.TrackerType Type { get; set; }

Property Value

XRServer.TrackerType

Methods

GetInput(StringName)

Returns an input for this tracker. It can return a boolean, float or Vector2 value depending on whether the input is a button, trigger or thumbstick/thumbpad.

public Variant GetInput(StringName name)

Parameters

name StringName

Returns

Variant

GetPose(StringName)

Returns the current XRPose state object for the bound name pose.

public XRPose GetPose(StringName name)

Parameters

name StringName

Returns

XRPose

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

HasPose(StringName)

Returns true if the tracker is available and is currently tracking the bound name pose.

public bool HasPose(StringName name)

Parameters

name StringName

Returns

bool

InvalidatePose(StringName)

Marks this pose as invalid, we don't clear the last reported state but it allows users to decide if trackers need to be hidden if we lose tracking or just remain at their last known position.

public void InvalidatePose(StringName name)

Parameters

name StringName

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SetInput(StringName, Variant)

Changes the value for the given input. This method is called by a XRInterface implementation and should not be used directly.

public void SetInput(StringName name, Variant value)

Parameters

name StringName
value Variant

SetPose(StringName, Transform3D, Vector3, Vector3, TrackingConfidenceEnum)

Sets the transform, linear velocity, angular velocity and tracking confidence for the given pose. This method is called by a XRInterface implementation and should not be used directly.

public void SetPose(StringName name, Transform3D transform, Vector3 linearVelocity, Vector3 angularVelocity, XRPose.TrackingConfidenceEnum trackingConfidence)

Parameters

name StringName
transform Transform3D
linearVelocity Vector3
angularVelocity Vector3
trackingConfidence XRPose.TrackingConfidenceEnum

Events

ButtonPressed

Emitted when a button on this tracker is pressed. Note that many XR runtimes allow other inputs to be mapped to buttons.

public event XRPositionalTracker.ButtonPressedEventHandler ButtonPressed

Event Type

XRPositionalTracker.ButtonPressedEventHandler

ButtonReleased

Emitted when a button on this tracker is released.

public event XRPositionalTracker.ButtonReleasedEventHandler ButtonReleased

Event Type

XRPositionalTracker.ButtonReleasedEventHandler

InputFloatChanged

Emitted when a trigger or similar input on this tracker changes value.

public event XRPositionalTracker.InputFloatChangedEventHandler InputFloatChanged

Event Type

XRPositionalTracker.InputFloatChangedEventHandler

InputVector2Changed

Emitted when a thumbstick or thumbpad on this tracker moves.

public event XRPositionalTracker.InputVector2ChangedEventHandler InputVector2Changed

Event Type

XRPositionalTracker.InputVector2ChangedEventHandler

PoseChanged

Emitted when the state of a pose tracked by this tracker changes.

public event XRPositionalTracker.PoseChangedEventHandler PoseChanged

Event Type

XRPositionalTracker.PoseChangedEventHandler

PoseLostTracking

Emitted when a pose tracked by this tracker stops getting updated tracking data.

public event XRPositionalTracker.PoseLostTrackingEventHandler PoseLostTracking

Event Type

XRPositionalTracker.PoseLostTrackingEventHandler

ProfileChanged

Emitted when the profile of our tracker changes.

public event XRPositionalTracker.ProfileChangedEventHandler ProfileChanged

Event Type

XRPositionalTracker.ProfileChangedEventHandler