spawn behavior

This commit is contained in:
bee
2026-07-09 14:45:53 +02:00
parent e78d11998f
commit db201081f5
5 changed files with 63 additions and 8 deletions
+14 -2
View File
@@ -6,6 +6,7 @@ extends Node
if current_controlled != null and current_controlled != value:
current_controlled.desired_throttle = 0.0
current_controlled.steer_input = 0.0
current_controlled.fire_intents.clear()
current_controlled = value
if is_node_ready():
if current_controlled != null:
@@ -56,9 +57,12 @@ func _process(delta: float) -> void:
current_controlled.desired_throttle = desired_throttle
current_controlled.steer_input = steer_input
if Input.is_action_pressed("fire"):
current_controlled.fire_weapons()
current_controlled.fire_intents[0] = Input.is_action_pressed("fire")
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed(&"debug_possess_next"):
_possess_next()
func _possess() -> void:
if camera_rig != null:
camera_rig.target = current_controlled
@@ -66,3 +70,11 @@ func _possess() -> void:
world_manager.focus = current_controlled
if hud != null:
hud.boat = current_controlled
func _possess_next() -> void:
var boats := get_tree().get_nodes_in_group(&"boats")
if boats.is_empty():
current_controlled = null
return
var idx := boats.find(current_controlled)
current_controlled = boats[(idx + 1) % boats.size()]