Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

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");

    }
    }
    }