How to add the accelerometer / gyroscope to a kinetic body

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

I really need someone to hold my hand with this one
and treat me like a beginner. The online instructions and
youtube videos aren’t working.

So I have a kinetic body 3d, it’s basically just the
floor of my game. I want to simply add either the
accelerometer or gyroscope ( not sure what one to use )
to the floor so when I tilt my phone the floor will tilt in the
same direction.

My current code:

var rotationn = Vector3(0,0,0)

const SPEED = 6

func _process(delta):

var rotationn = Input.get_gyroscope()

move_and_slide(vector3(rotationn.y, 0, rotationn.x) *

SPEED, Vector3.ZERO)

pass

The platform will move back and forth depending on the
direction my phone is tilted in but it doesn’t tilt, it just moves
in the direction I am tilting and slides across the screen, I want the floor to actually tilt
and I want the floor to remain stationary, I want it to stay
where it is but tilt in the direction my phone is tilting in.

Thanks, I hope I was clear enough. My code is probably completely
wrong, it was just the closest I could get for it to perform the task
I wanted it to do.

:bust_in_silhouette: Reply From: code

First I think instead of kinematic body, you should use a rigid body. You won’t need to write lot of code if you do it right. Second you will need to look for formula to apply that velocity for the tilt to the rotation of the floor