Setting animator parameter on a single instance of a prefab sets the parameter for all instances

I have created a Prefab with the intention of creating many instances of the same GameObject. However whilst I would like all of these instances to use the same Animations and Animation Controller, I want to be able to control the state for each instance independantly.

My Prefab currently consists of a Sprite Renderer, Script, Box Collider 2D and Animator. The Animator has an Animation Controller which has two states that are controlled using a boolean parameter.

The Script contains the following code:

private Animator _animator;
private bool _isAlive;

private void Start()
{
    _animator = gameObject.GetComponent<Animator>();
}

void Update ()
{
    if (Input.GetMouseButtonDown(0))
    {
        var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
        _isAlive = hit.collider == null;
    }

    _animator.SetBool("isAlive", _isAlive);
}

The Animations are both created using sprite sheets.

So in my example I would like the Animator to only animate the GameObject that has been clicked. The click detection part works fine but all instances of the GameObject animate when any GameObject is clicked.

i think you could use the function OnMouseClick()
this function detects if you clicked on the object.

so the script will be something like this:

private Animator _animator;
        
 private void Start()
{
             _animator = gameObject.GetComponent<Animator>();
}
        
void OnMouseDown()
{
            _animator.SetBool("isAlive", false) //you can set this to true or false.
 }

Just wondering if there was a solution to this yet? (Other than creating a new animator for each object.)

Since every object calls the Update method, every object detects the mouse click. You would need to select the object first or find a different way to make sure that only the object you want performs the action. See at my answer here for the selection: How do I get objects to move different speeds? - Unity Answers