![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | NoIE |
This is my code:
extends Node2D
var low = -1.5
var current = false
var timer = 0.0
var code = ""
# Called when the node enters the scene tree for the first time.
func _ready():
low = Input.get_accelerometer().x
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var threshold
var accX = Input.get_accelerometer().x
if current:
threshold = low+0.2
timer = timer + delta #When pressdown, it will be timing.
else:
threshold = low+0.4
if timer > 0: #When pressup, it will be calculate the duration of the press.
if timer > 0.2:
code = code + "-" #long
else:
code = code + "." #short
timer = 0
$console.text = code
current = accX > threshold #Detect pressing
func _on_calibration_pressed():
low = Input.get_accelerometer().x
When I click the phone, it show irregular garbled. I guess the gyroscope sensor is not accurate enough.
I don’t know where the problem is.
Maybe my code isn’t good enough, maybe I should add low-pass filtering. maybe it’s a bad idea to simulate a telegram with gyroscope sensor.
You didn’t say what the problem is. What does it do, or not do, that’s the issue?
jgodfrey | 2020-02-22 03:41
When I click the phone, it show irregular garbled. I guess the gyroscope sensor is not accurate enough.
Btw, I use a old Nexus5 phone test my game.
NoIE | 2020-02-22 12:03