Skip to content

Add mobile sensors tutorial (WIP)#12089

Draft
Nintorch wants to merge 1 commit into
godotengine:masterfrom
Nintorch:mobile-sensors-tutorial
Draft

Add mobile sensors tutorial (WIP)#12089
Nintorch wants to merge 1 commit into
godotengine:masterfrom
Nintorch:mobile-sensors-tutorial

Conversation

@Nintorch

Copy link
Copy Markdown
Member

This PR adds a mobile sensors tutorial. The mobile sensors include motion sensors (accelerometer and gyroscope), as well as the magnetometer sensor.

I'm creating this PR now so I won't forget about it in the future :D

@Nintorch Nintorch added area:manual Issues and PRs related to the Manual/Tutorials section of the documentation topic:input platform:ios Issues or PRs related specifically to ios platform:android labels Jun 22, 2026

@Cykyrios Cykyrios left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few formatting remarks and a pitch/roll inversion.

The last code example mentions detecting opposite "movement", when in reality the sequence of events is acceleration in one direction -> maybe no acceleration for a short while -> acceleration ~opposite to initial acceleration -> device comes to a stop. The device has technically been moving in a single direction the entire time, but I understand you mean to say the reported value shows the deceleration as that "opposite movement".

Comment on lines +27 to +29
- the X value of the gyroscope data shows the rotation around the X axis (roll).
- the Y value of the gyroscope data shows the rotation around the Y axis (yaw).
- the Z value of the gyroscope data shows the rotation around the Z axis (pitch).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- the X value of the gyroscope data shows the rotation around the X axis (roll).
- the Y value of the gyroscope data shows the rotation around the Y axis (yaw).
- the Z value of the gyroscope data shows the rotation around the Z axis (pitch).
- the X value of the gyroscope data shows the rotation around the X axis (pitch).
- the Y value of the gyroscope data shows the rotation around the Y axis (yaw).
- the Z value of the gyroscope data shows the rotation around the Z axis (roll).
Comment on lines +60 to +61
.. note::
For Android,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. note::
For Android,
.. note::
On Android,
.. warning::

Do not use accelerometer data to find the controller's position in 3D space;
the accelerometers in general are not precise enough for this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the accelerometers in general are not precise enough for this.
accelerometers in general are not precise enough for this.
Comment on lines +91 to +92
.. note::
For Android,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. note::
For Android,
.. note::
On Android,
Comment on lines +11 to +15
.. note::

Controller motion sensors usage is explained in detail
on the :ref:`doc_controller_features_motion_sensors` page.
This page describes how to use the sensors found in mobile phones on Android and iOS.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a similar note on the Controller motion sensors section of that page, pointing to this page.

Comment on lines +148 to +149
Magnetometer
~~~~~~~~~~~~~

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Magnetometer
~~~~~~~~~~~~~
Magnetometer
~~~~~~~~~~~~
With motion controls, games can track the device's physical rotation and movement.
This can be used to let the player turn the in-game camera by moving their device, or shaking their device to perform a special action.

The device in this case can be either a mobile phone or a controller.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to imply this applies to controllers, but below it says phones only?

~~~~~~~~~~~~~~~~

Mobile sensor input methods, such as :ref:`Input.get_gyroscope()<class_Input_method_get_gyroscope>`,
return :ref:`Vector3<class_Vector3>`, which corresponds to X, Y, and Z axes of the reported data,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return :ref:`Vector3<class_Vector3>`, which corresponds to X, Y, and Z axes of the reported data,
return :ref:`Vector3<class_Vector3>`, which corresponds to the X, Y, and Z axes of the reported data,
For Android,
:ref:`input_devices/sensors/enable_accelerometer<class_ProjectSettings_property_input_devices/sensors/enable_accelerometer>`
and :ref:`input_devices/sensors/enable_gravity<class_ProjectSettings_property_input_devices/sensors/enable_gravity>`
must be enabled for the accelerometer and the gravity sensors respectively to start reporting values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
must be enabled for the accelerometer and the gravity sensors respectively to start reporting values.
must be enabled for the accelerometer and gravity sensors respectively to start reporting values.

The following example rotates an object using the mobile device's gyroscope sensor.

.. code-block::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. code-block::
.. code-block:: gdscript

For all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:manual Issues and PRs related to the Manual/Tutorials section of the documentation platform:android platform:ios Issues or PRs related specifically to ios topic:input

4 participants