This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I have 3d game, and i don’t know how to input accelerometer. I’m trying to input this script but doesn’t working good

extends KinematicBody
var gravity = Vector3.Down*25
var speed = 8 
var velocity = vector3()

func _physics_process(delta):
get_input()
velocity = move_and_slide(velocity, Vector3.UP)

func get_input():
velocity.x = 0
velocity.y = 0
if Input.get_accelerometer().x<0:
       velocity.x -= speed
if Input.get_accelerometer().x<0:
       velocity.x += speed
if Input.get_accelerometer().z<0:
       velocity.z += speed
if Input.get_accelerometer().z<0:
       velocity.z -= speed

How to make better?

in Engine by (23 points)

1 Answer

0 votes

Maybe this can help you out:
"A demo showing the use of various sensors: a accelerometer, a gyroscope and a magnetometer."
https://github.com/godotengine/godot-demo-projects/tree/3.0-d69cc10/misc/sensors

You can also find it at the Templates tab on the Project Manager Window.
Just search for "sensors" (without quotes, of course.... :) )
enter image description here
enter image description here

by (14 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.