Question by 
               loafy123 · Sep 17, 2021 at 10:53 AM · 
                animationanimatorunity 2danimationclip  
              
 
              One script to call animation on different objects
Hi I am doing 3 objects each will have animation when onClick and I attached the same script for them
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 
 public class click_item : MonoBehaviour
 {
     public GameObject item;
     public AudioSource getItemsfx;
     public Animator revealanim;
 
     // Start is called before the first frame update
     void Start()
     {
         
     }
 
     // Update is called once per frame
     void Update()
     {
         
     }
 
     void OnMouseDown()
     {
         getItemsfx.Play();
          Destroy(gameObject);
          item.SetActive(true);
         revealanim.Play("clipname");
     }
 
   
 }
 
 
               The normal way is anim.Play("clipname"), but the clip name for each object is different. So is there any other way to solve this? I don't want to create multiple same scripts.
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Sprite animation only playing first frame 3 Answers
change player position when animation in played 0 Answers
Why isn't my animation looping? 3 Answers
Attaching animation clip in Motion of state in animator? 0 Answers
Animation Constantly Playing? 1 Answer