fix: dead player ragdoll no longer triggers leaving the combat area
This commit is contained in:
+14
-1
@@ -18,6 +18,12 @@ func _ready() -> void:
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if _player_out_of_bounds:
|
||||
# If the player dies while out of bounds, stop the timer and remove the UI
|
||||
if "is_dead" in _player_out_of_bounds and _player_out_of_bounds.is_dead:
|
||||
_player_out_of_bounds = null
|
||||
_remove_ui()
|
||||
return
|
||||
|
||||
# Player is outside the combat area!
|
||||
time_left -= delta
|
||||
if time_left <= 0.0:
|
||||
@@ -39,6 +45,12 @@ func _process(delta: float) -> void:
|
||||
|
||||
func _on_body_exited(body: Node3D) -> void:
|
||||
if body.name == "Player":
|
||||
# Don't trigger if the player is already dead or the scene is tearing down
|
||||
if "is_dead" in body and body.is_dead:
|
||||
return
|
||||
if body.is_queued_for_deletion() or not is_inside_tree():
|
||||
return
|
||||
|
||||
_player_out_of_bounds = body
|
||||
time_safe = 0.0 # Reset recovery timer
|
||||
_create_ui()
|
||||
@@ -74,7 +86,8 @@ func _create_ui() -> void:
|
||||
|
||||
_ui_layer.add_child(_ui_label)
|
||||
|
||||
get_tree().current_scene.add_child(_ui_layer)
|
||||
if get_tree().current_scene:
|
||||
get_tree().current_scene.call_deferred("add_child", _ui_layer)
|
||||
|
||||
func _remove_ui() -> void:
|
||||
if _ui_layer:
|
||||
|
||||
Reference in New Issue
Block a user