Hi. I made a RigidBody2D named Zombie 1, I have a basic script to it, one which shows it’s health and one that plays it’s idle animation. I want it to move towards CharacterBody2D named main_character and damage it until it dies or is out of range.
Here is the script
extends RigidBody2D
var health = 50
@onready var zombie_health = $zombie_health
func _ready():
var mob_types = $AnimatedSprite2D.sprite_frames.get_animation_names()
$AnimatedSprite2D.play(mob_types[randi() % mob_types.size()])
zombie_health.text = str(int(health))
func _on_visible_on_screen_notifier_2d_screen_exited():
queue_free()