Added locked barriers and a new ghost enemy
This commit is contained in:
28
Enemies/Chasing Glowing Ghost.gd
Normal file
28
Enemies/Chasing Glowing Ghost.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
const SPEED: int = 50
|
||||
|
||||
var player: KinematicBody2D = null
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player and position.distance_to(player.position) > 1:
|
||||
velocity = position.direction_to(player.position).normalized() * SPEED
|
||||
|
||||
velocity = move_and_slide(velocity)
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_entered(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = body
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_body_exited(body: Node) -> void:
|
||||
if body.is_in_group('player'):
|
||||
player = null
|
||||
return
|
Reference in New Issue
Block a user