using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SpiritScript : MonoBehaviour {
|
|
|
|
public GameObject pivot;
|
|
float speed = 55.0f;
|
|
float jitterTime = 2.0f;
|
|
|
|
public float progress = 0;
|
|
|
|
public void Start()
|
|
{
|
|
StartCoroutine("Move");
|
|
}
|
|
|
|
IEnumerator Move()
|
|
{
|
|
bool moving = true;
|
|
float rand = Random.Range(40.0f, 180.0f);
|
|
while (moving == true)
|
|
{
|
|
float distance = speed * Time.deltaTime;
|
|
progress += distance;
|
|
gameObject.transform.RotateAround(pivot.transform.position,pivot.transform.forward, distance);
|
|
if (progress > rand)
|
|
{
|
|
rand = Random.Range(0, 0.5f);
|
|
yield return new WaitForSeconds(rand);
|
|
rand = Random.Range(40.0f, 180.0f);
|
|
progress = 0;
|
|
speed = Random.Range(60.0f, 90.0f);
|
|
}
|
|
yield return new WaitForEndOfFrame();
|
|
}
|
|
|
|
}
|
|
}
|