Major collision detection improvements, more file organization, and added key interactable
This commit is contained in:
@@ -9,20 +9,20 @@ var velocity: Vector2 = Vector2.ZERO
|
||||
func _physics_process(_delta: float) -> void:
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
if player:
|
||||
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_area_entered(area: Area2D) -> void:
|
||||
if area.get_parent().name == 'Player':
|
||||
player = area.get_parent()
|
||||
func _on_player_detector_body_entered(body: Node) -> void:
|
||||
if 'player' in body.get_groups():
|
||||
player = body
|
||||
return
|
||||
|
||||
|
||||
func _on_player_detector_area_exited(area: Area2D):
|
||||
if area.get_parent().name == 'Player':
|
||||
func _on_player_detector_body_exited(body: Node) -> void:
|
||||
if 'player' in body.get_groups():
|
||||
player = null
|
||||
return
|
||||
|
Reference in New Issue
Block a user