docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Gyroscope

    Input device representing a gyroscope sensor.

    Inheritance
    object
    InputControl
    InputDevice
    Sensor
    Gyroscope
    AndroidGyroscope
    Inherited Members
    Sensor.samplingFrequency
    InputDevice.InvalidDeviceId
    InputDevice.description
    InputDevice.enabled
    InputDevice.canRunInBackground
    InputDevice.added
    InputDevice.remote
    InputDevice.native
    InputDevice.updateBeforeRender
    InputDevice.deviceId
    InputDevice.lastUpdateTime
    InputDevice.wasUpdatedThisFrame
    InputDevice.allControls
    InputDevice.valueType
    InputDevice.valueSizeInBytes
    InputDevice.ReadValueFromBufferAsObject(void*, int)
    InputDevice.ReadValueFromStateAsObject(void*)
    InputDevice.ReadValueFromStateIntoBuffer(void*, void*, int)
    InputDevice.CompareValue(void*, void*)
    InputDevice.OnAdded()
    InputDevice.OnConfigurationChanged()
    InputDevice.ExecuteCommand<TCommand>(ref TCommand)
    InputDevice.ExecuteCommand(InputDeviceCommand*)
    InputControl.name
    InputControl.displayName
    InputControl.shortDisplayName
    InputControl.path
    InputControl.layout
    InputControl.variants
    InputControl.device
    InputControl.parent
    InputControl.children
    InputControl.usages
    InputControl.aliases
    InputControl.stateBlock
    InputControl.noisy
    InputControl.synthetic
    InputControl.this[string]
    InputControl.magnitude
    InputControl.ToString()
    InputControl.EvaluateMagnitude()
    InputControl.EvaluateMagnitude(void*)
    InputControl.WriteValueFromBufferIntoState(void*, int, void*)
    InputControl.WriteValueFromObjectIntoState(object, void*)
    InputControl.TryGetChildControl(string)
    InputControl.TryGetChildControl<TControl>(string)
    InputControl.GetChildControl(string)
    InputControl.GetChildControl<TControl>(string)
    InputControl.RefreshConfigurationIfNeeded()
    InputControl.RefreshConfiguration()
    InputControl.m_StateBlock
    InputControl.currentStatePtr
    InputControl.previousFrameStatePtr
    InputControl.defaultStatePtr
    InputControl.noiseMaskPtr
    InputControl.stateOffsetRelativeToDeviceRoot
    InputControl.optimizedControlDataType
    InputControl.CalculateOptimizedControlDataType()
    InputControl.ApplyParameterChanges()
    Namespace: UnityEngine.InputSystem
    Assembly: Unity.InputSystem.dll
    Syntax
    public class Gyroscope : Sensor
    Remarks

    A gyroscope lets you measure the angular velocity of a device, and can be useful to control content by rotating a device.

    Whether the platform removes the sensor's bias from this value depends on the platform. Use BiasCorrectedGyroscope instead when you need the bias to be removed on every platform that provides the device. For what bias is and why it matters when you integrate the value, refer to Gyroscope bias and drift.

    Properties

    angularVelocity

    Angular velocity of the device in radians per second.

    Declaration
    public Vector3Control angularVelocity { get; protected set; }
    Property Value
    Type Description
    Vector3Control
    Remarks

    The axes are fixed to the device in a right-handed frame: X points right, Y points up, and Z points out of the screen. Positive rotation follows the right-hand rule, so a rotation is positive when it appears counter-clockwise to an observer looking at the device from the positive end of an axis.

    This is the platform's own frame rather than Unity's left-handed convention, so account for the difference when you apply the value to a Transform.

    The axes don't change with device orientation. When compensateForScreenOrientation is enabled, the value is rotated to match the current screen orientation.

    See Also
    BiasCorrectedGyroscope

    current

    The gyroscope that was last added or had activity last.

    Declaration
    public static Gyroscope current { get; }
    Property Value
    Type Description
    Gyroscope

    Current gyroscope or null.

    See Also
    BiasCorrectedGyroscope

    Methods

    FinishSetup()

    Perform final initialization tasks after the control hierarchy has been put into place.

    Declaration
    protected override void FinishSetup()
    Overrides
    InputControl.FinishSetup()
    Remarks

    This method can be overridden to perform control- or device-specific setup work. The most common use case is for looking up child controls and storing them in local getters.

    Examples
      public class MyDevice : InputDevice
                            {
                                public ButtonControl button { get; private set; }
                                public AxisControl axis { get; private set; }
    
                                protected override void OnFinishSetup()
                                {
                                    // Cache controls in getters.
                                    button = GetChildControl("button");
                                    axis = GetChildControl("axis");
                                }
                            }
    
    See Also
    BiasCorrectedGyroscope

    MakeCurrent()

    Make this the current device of its type.

    Declaration
    public override void MakeCurrent()
    Overrides
    InputDevice.MakeCurrent()
    Remarks

    This method is called automatically by the input system when a device is added or when input is received on it. Many types of devices have .current getters that allow querying the last used device of a specific type directly (for example, see current).

    There is one special case, however, related to noise. A device that has noisy controls (i.e. controls for which noisy is true) may receive input events that contain no meaningful user interaction but are simply just noise from the device. A good example of this is the PS4 gamepad which has a built-in gyro and may thus constantly feed events into the input system even if not being actually in use. If, for example, an Xbox gamepad and PS4 gamepad are both connected to a PC and the user is playing with the Xbox gamepad, the PS4 gamepad would still constantly make itself current by simply flooding the system with events. Hence why by default, noise on .current getters will be filtered out and a device will only see MakeCurrent getting called if their input was detected on non-noisy controls.

    See Also
    current
    current
    current
    current

    OnRemoved()

    Called by the system when the device is removed from devices.

    Declaration
    protected override void OnRemoved()
    Overrides
    InputDevice.OnRemoved()
    Remarks

    This is called after the device has already been removed. devicesRemovedOnAdded()

    Examples
      using UnityEngine.InputSystem;
    
                                                                                                                                                                                                                                  public class MyDevice : InputDevice
                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                      public static MyDevice current { get; private set; }
                                                                                                                                                                                                                                      protected override void OnRemoved()
                                                                                                                                                                                                                                      {
                                                                                                                                                                                                                                          // use this context to unassign the current device for instance
                                                                                                                                                                                                                                          base.OnRemoved();
                                                                                                                                                                                                                                          if (current == this)
                                                                                                                                                                                                                                              current = null;
                                                                                                                                                                                                                                      }
                                                                                                                                                                                                                                  }
    
    See Also
    BiasCorrectedGyroscope

    Extension Methods

    InputControlExtensions.CheckStateIsAtDefault(InputControl)
    InputControlExtensions.CheckStateIsAtDefault(InputControl, void*, void*)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl, void*)
    InputControlExtensions.CompareState(InputControl, void*, void*)
    InputControlExtensions.CompareState(InputControl, void*, void*, void*)
    InputControlExtensions.CompareStateIgnoringNoise(InputControl, void*)
    InputControlExtensions.FindControlsRecursive<TControl>(InputControl, IList<TControl>, Func<TControl, bool>)
    InputControlExtensions.FindInParentChain<TControl>(InputControl)
    InputControlExtensions.GetStatePtrFromStateEvent(InputControl, InputEventPtr)
    InputControlExtensions.HasValueChangeInEvent(InputControl, InputEventPtr)
    InputControlExtensions.HasValueChangeInState(InputControl, void*)
    InputControlExtensions.IsActuated(InputControl, float)
    InputControlExtensions.IsPressed(InputControl, float)
    InputControlExtensions.ReadDefaultValueAsObject(InputControl)
    InputControlExtensions.ReadValueAsObject(InputControl)
    InputControlExtensions.ReadValueFromEventAsObject(InputControl, InputEventPtr)
    InputControlExtensions.ReadValueIntoBuffer(InputControl, void*, int)
    InputControlExtensions.ResetToDefaultStateInEvent(InputControl, InputEventPtr)
    InputControlExtensions.WriteValueFromObjectIntoEvent(InputControl, InputEventPtr, object)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl, TValue, InputEventPtr)
    InputControlExtensions.WriteValueIntoState(InputControl, void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl, TValue, void*)
    InputControlExtensions.CopyState(InputDevice, void*, int)
    InputControlExtensions.CopyState<TState>(InputDevice, out TState)

    See Also

    BiasCorrectedGyroscope
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)