mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-22 07:44:17 +00:00
Default to down gravity if accelerometer is not supported
This commit is contained in:
parent
f844cd02d2
commit
40089db03a
2 changed files with 3 additions and 3 deletions
|
@ -4,6 +4,8 @@ class_name GravityFromGyro
|
||||||
|
|
||||||
func _physics_process(_delta):
|
func _physics_process(_delta):
|
||||||
var accel_3d = Input.get_accelerometer()
|
var accel_3d = Input.get_accelerometer()
|
||||||
|
if accel_3d == Vector3.ZERO: # If accelerometer is not supported
|
||||||
|
accel_3d = Vector3.DOWN * 9.8
|
||||||
|
|
||||||
var accel_2d = Vector2(accel_3d.x, -accel_3d.y) / 9.8
|
var accel_2d = Vector2(accel_3d.x, -accel_3d.y) / 9.8
|
||||||
PhysicsServer2D.area_set_param(get_viewport().find_world_2d().space, PhysicsServer2D.AREA_PARAM_GRAVITY_VECTOR, accel_2d)
|
PhysicsServer2D.area_set_param(get_viewport().find_world_2d().space, PhysicsServer2D.AREA_PARAM_GRAVITY_VECTOR, accel_2d)
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,6 @@ texture_filter = 1
|
||||||
[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||||
position = Vector2(-24, -490)
|
position = Vector2(-24, -490)
|
||||||
scene = ExtResource("2_dv01l")
|
scene = ExtResource("2_dv01l")
|
||||||
target_parent = NodePath("..")
|
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"]
|
[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"]
|
||||||
autostart = true
|
autostart = true
|
||||||
|
@ -89,7 +88,6 @@ autostart = true
|
||||||
[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||||
position = Vector2(24, -490)
|
position = Vector2(24, -490)
|
||||||
scene = ExtResource("2_dv01l")
|
scene = ExtResource("2_dv01l")
|
||||||
target_parent = NodePath("..")
|
|
||||||
|
|
||||||
[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"]
|
[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"]
|
||||||
[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"]
|
[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"]
|
||||||
|
|
Loading…
Reference in a new issue