get_accelerometer() does not work

Godot Version

Godot 4.x, but also failed in 3.x

Question

I want to make a simple marble game for Android devices. But I can’t get get_accelerometer() to work. It only gives me Vector.ZERO or (0.0, 0.0, 0.0)

I tried on different phones.

the most simple Test was: Node3D → CanvasLayer → Label and in a script attached to Node3D:

extends Node3D

func _physics_process(delta: float) → void:
$CanvasLayer/Label.text = str(Input.get_accelerometer())

All it shows is (0.0, 0.0, 0.0)

Can anybody help?

1 Like

Did you try create variable with

var accelerometer = Input.get_accelerometer()

then try print it , I recommend to use it in function during _process

I’m not sure if there’s a permission for reading the accelerometers. A lot of stuff on mobile silently fails if you haven’t asked for and received permission.

Hello thank you for your replies.

I found the Problem: I have to enable Sensors under Inputs in the Project Settings in Godot.

Maybe this helps somebody else in the future

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.