extends KinematicBody2D onready var immunity = 5 const MOVEMENT_VECTORS = [ Vector2.UP, Vector2.RIGHT, Vector2.DOWN, Vector2.LEFT ] func _physics_process(_delta): if immunity > 0: immunity = immunity - 1 var movement = MOVEMENT_VECTORS[randi() % 4] move_and_collide(movement * 2) func _on_Hurtbox_area_entered(_area): if immunity == 0: $Hurtbox/death.play() func _on_death_finished(): queue_free() func _on_Hitbox_area_entered(_area): yield(get_tree().create_timer(2.0),"timeout") var ooze = load("res://NPCs/ooze.tscn") var instance = ooze.instance() instance.position = position get_parent().add_child(instance) queue_free()