Is it possible to move my character by only moving my mobile device with Godto Engine?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ranto Mamisoa

Hello everyone,
I have a problem with the control handling for mobile devices.
I want my character to move when I move my phone, like driving in a racing game.
Thanks already to those who will answer.
Good continuation to all.

:bust_in_silhouette: Reply From: jgodfrey

Generally, you’re looking for Input.get_accelerometer().

See the docs here:

A simple use could look like this:

func _process(delta):
    var pos = position

    if Globals.isMobile:
        vel.x = MOVE_SPEED * Input.get_accelerometer().x * 0.4

    position += vel * delta