You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
893 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class ChestDemo : MonoBehaviour {
  5. //This script goes on the ChestComplete prefab;
  6. public Animator chestAnim; //Animator for the chest;
  7. // Use this for initialization
  8. void Awake ()
  9. {
  10. //get the Animator component from the chest;
  11. chestAnim = GetComponent<Animator>();
  12. //start opening and closing the chest for demo purposes;
  13. StartCoroutine(OpenCloseChest());
  14. }
  15. IEnumerator OpenCloseChest()
  16. {
  17. //play open animation;
  18. chestAnim.SetTrigger("open");
  19. //wait 2 seconds;
  20. yield return new WaitForSeconds(2);
  21. //play close animation;
  22. chestAnim.SetTrigger("close");
  23. //wait 2 seconds;
  24. yield return new WaitForSeconds(2);
  25. //Do it again;
  26. StartCoroutine(OpenCloseChest());
  27. }
  28. }