From 3fdb011ef62249a514a8eba2556cc9f6ea5ea477 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 10 Sep 2024 18:16:15 +0200 Subject: next commit --- Enemies/Enemy.tscn | 2 ++ Enemies/enemy.gd | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'Enemies') diff --git a/Enemies/Enemy.tscn b/Enemies/Enemy.tscn index ac2cb22..678b33a 100644 --- a/Enemies/Enemy.tscn +++ b/Enemies/Enemy.tscn @@ -34,5 +34,7 @@ texture_filter = 1 sprite_frames = SubResource("SpriteFrames_n2gm8") [node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."] +process_mode = 3 [connection signal="screen_entered" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_entered"] +[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"] diff --git a/Enemies/enemy.gd b/Enemies/enemy.gd index 5818fb4..ab1ceac 100644 --- a/Enemies/enemy.gd +++ b/Enemies/enemy.gd @@ -5,7 +5,7 @@ const SPEED = 30 func _ready() -> void: - set_physics_process(false) + process_mode = PROCESS_MODE_DISABLED func _physics_process(delta: float) -> void: @@ -20,4 +20,8 @@ func _physics_process(delta: float) -> void: func _on_visible_on_screen_notifier_2d_screen_entered() -> void: - set_physics_process(true) + process_mode = PROCESS_MODE_INHERIT + + +func _on_visible_on_screen_notifier_2d_screen_exited() -> void: + process_mode = PROCESS_MODE_DISABLED -- cgit v1.2.3