theMessyCoder

PlayAnimation

Jan 2nd, 2022 (edited)
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. /*****************************************************
  2. // Author: The Messy Coder
  3. // Date: January 2022
  4. // For this video review: https://youtu.be/d8Oe1ydME7E
  5. // Please support by following on Twitch & social media
  6. // Twitch:   www.Twitch.tv/TheMessyCoder
  7. // YouTube:  www.YouTube.com/TheMessyCoder
  8. // Facebook: www.Facebook.com/TheMessyCoder
  9. // Twitter:  www.Twitter.com/TheMessyCoder
  10. *****************************************************/
  11.  
  12. using UnityEngine;
  13.  
  14. namespace Messy
  15. {
  16.     public class PlayAnimation : MonoBehaviour
  17.     {
  18.         [SerializeField]
  19.         private bool m_PlayAnimOnce = true;
  20.         [SerializeField] private Animation m_Anim;
  21.         bool hasPlayed = false;
  22.         [SerializeField] private string m_AnimClip;
  23.  
  24.         public void Play()
  25.         {
  26.             if (m_PlayAnimOnce == true && hasPlayed == false || m_PlayAnimOnce == false)
  27.             {
  28.                 m_Anim.Play(m_AnimClip);
  29.                 hasPlayed = true;
  30.             }
  31.         }
  32.     }
  33. }
  34.  
Add Comment
Please, Sign In to add comment