Major collision detection improvements, more file organization, and added key interactable

This commit is contained in:
VoidTwo
2021-12-04 00:07:33 -06:00
parent ca2ea40b23
commit fcea3cee03
18 changed files with 155 additions and 59 deletions

View File

@@ -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