Search Unity

Death animation working same object, why?

Discussion in 'Animation' started by thebuzzie, Jun 11, 2022.

  1. thebuzzie

    thebuzzie

    Joined:
    Nov 2, 2021
    Posts:
    2
    I'm working on a runner game project and main character gathering each guy hit. And in OnTriggerEnter method I add death animation collider trigger. Its work but when i hit an object other objects getting animating too. I can't fix it. Here is my scripts


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class gathering : MonoBehaviour
    {

    private void OnTriggerEnter (Collider other)
    {
    if (other.tag == "Player")
    {

    FindObjectOfType<audioManager>().PlaySound("Hit");

    playerManager.numberOfGathering += 1;

    Destroy(gameObject, 2);

    GetComponent<Animator>().Play("flyingDeathBack");

    }
    }
    }