I have an issue where I want to have 2 copies of the same enemy scene but I want the scripts for each to run independantly of each other.
I have 2 test enemies that I have written some very basic code for to test this. The issue I am getting is if I colide with the raycast of 1 enemy, the animation plays on both at the same time. I’m very confused because the health variable does act independently? Please can someone tell me in what way I am being dumb here!
extends CharacterBody3D
var health = 500 @onready var aim_cast = $EnemyAimCast @onready var animation_player = $AnimationPlayer
func _process(delta):
if health <= 0:
queue_free()
if aim_cast.is_colliding():
animation_player.play("2_alert")
else:
animation_player.play("1_idle")
Off the cuff, I’d say you need to “make local to scene” or “make unique” the animation or associated resource. Not on my computer or I’d give you a better answer.
Edit: generally when one change is affecting many things, it is because Godot is using only one copy of that resource to be efficient. And the fix is usually something like what I said above.