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.

39 lines
1.0 KiB

5 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SpiritScript : MonoBehaviour {
  5. public GameObject pivot;
  6. float speed = 55.0f;
  7. float jitterTime = 2.0f;
  8. public float progress = 0;
  9. public void Start()
  10. {
  11. StartCoroutine("Move");
  12. }
  13. IEnumerator Move()
  14. {
  15. bool moving = true;
  16. float rand = Random.Range(40.0f, 180.0f);
  17. while (moving == true)
  18. {
  19. float distance = speed * Time.deltaTime;
  20. progress += distance;
  21. gameObject.transform.RotateAround(pivot.transform.position,pivot.transform.forward, distance);
  22. if (progress > rand)
  23. {
  24. rand = Random.Range(0, 0.5f);
  25. yield return new WaitForSeconds(rand);
  26. rand = Random.Range(40.0f, 180.0f);
  27. progress = 0;
  28. speed = Random.Range(60.0f, 90.0f);
  29. }
  30. yield return new WaitForEndOfFrame();
  31. }
  32. }
  33. }