diff options
Diffstat (limited to 'Enemies')
-rw-r--r-- | Enemies/Enemy.tscn | 2 | ||||
-rw-r--r-- | Enemies/enemy.gd | 8 |
2 files changed, 8 insertions, 2 deletions
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 |