GMTKGameJam2024/scripts/body.gd

26 lines
623 B
GDScript3
Raw Normal View History

2024-08-16 21:48:38 +01:00
class_name Body extends Node3D
2024-08-16 20:16:19 +01:00
2024-08-16 21:48:38 +01:00
@export var arms: Array[Arm]
2024-08-16 23:07:59 +01:00
@export var pull_strength: float = 5.0
2024-08-16 20:16:19 +01:00
2024-08-16 23:07:59 +01:00
var active_arm: Arm
2024-08-16 20:16:19 +01:00
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
2024-08-16 23:07:59 +01:00
pass
2024-08-16 20:16:19 +01:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
2024-08-16 23:07:59 +01:00
func _unhandled_input(event: InputEvent) -> void:
2024-08-16 21:24:48 +01:00
for arm in arms:
2024-08-16 23:07:59 +01:00
if Input.is_action_pressed(arm.action):
active_arm = arm
return
2024-08-16 21:24:48 +01:00
if Input.is_action_just_released(arm.action):
2024-08-16 23:07:59 +01:00
active_arm = null
return
func _physics_process(delta: float) -> void:
if active_arm == null: return
active_arm.update_target_pos()