preliminary support for controllers

This commit is contained in:
Taevas 2025-03-31 17:57:54 +02:00
parent 8f18e43af7
commit ff8bd770d2
4 changed files with 76 additions and 12 deletions

View file

@ -12,7 +12,7 @@ const stronger = normal * 3
func _input(_event: InputEvent) -> void:
if player_ready:
var grav = stronger if Input.is_key_pressed(KEY_SHIFT) else normal
var grav = stronger if Input.is_action_pressed(\"gravity_strong\") else normal
PhysicsServer3D.area_set_param(get_viewport().find_world_3d().space, PhysicsServer3D.AREA_PARAM_GRAVITY, grav)
"
@ -25,22 +25,26 @@ func _ready() -> void:
func _input(ev: InputEvent) -> void:
if ev is InputEventKey and ev.is_pressed():
var k = ev.keycode
if k == KEY_UP or k == KEY_RIGHT or k == KEY_LEFT or k == KEY_DOWN:
var up := Input.is_action_just_pressed(\"gravity_up\")
var left := Input.is_action_just_pressed(\"gravity_left\")
var right := Input.is_action_just_pressed(\"gravity_right\")
var down := Input.is_action_just_pressed(\"gravity_down\")
if up or left or right or down:
var direction = Vector3()
if k == KEY_UP:
if up:
direction = Vector3.UP
self.rotation_degrees = -90
$AudioStreamPlayer.pitch_scale = 1.05
elif k == KEY_LEFT:
elif left:
direction = Vector3.LEFT
self.rotation_degrees = -180
$AudioStreamPlayer.pitch_scale = 1.02
elif k == KEY_RIGHT:
elif right:
direction = Vector3.RIGHT
self.rotation_degrees = 0
$AudioStreamPlayer.pitch_scale = 0.98
elif k == KEY_DOWN:
elif down:
direction = Vector3.DOWN
self.rotation_degrees = 90
$AudioStreamPlayer.pitch_scale = 0.95