AudienceActionComp.cs 762 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using UnityEngine;
  3. using Random = UnityEngine.Random;
  4. namespace Comp
  5. {
  6. public class AudienceActionComp : MonoBehaviour
  7. {
  8. private Animator _animator;
  9. private const float MinY = -0.9f;
  10. private void Start()
  11. {
  12. _animator = GetComponent<Animator>();
  13. InvokeRepeating("Cheer", Random.Range(3f, 5f), Random.Range(3f, 5f));
  14. }
  15. private void Cheer()
  16. {
  17. _animator.ResetTrigger("cheer");
  18. _animator.SetTrigger("cheer");
  19. }
  20. private void FixedUpdate()
  21. {
  22. var position = transform.position;
  23. position = new Vector3(position.x, MinY, position.z);
  24. transform.position = position;
  25. }
  26. }
  27. }