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.
 
 
 

31 lines
782 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpiritJitter : MonoBehaviour {
Vector3 Target = new Vector3(0.0f, 0.0f, 0.0f);
public float distance = 1.0f;
public float time = 0.5f;
private void Start()
{
StartCoroutine("Jitter");
}
IEnumerator Jitter()
{
bool jittering = true;
while (jittering)
{
transform.localPosition = Target;
float randX = Random.Range(-1 * distance, distance);
float randY = Random.Range(-1 * distance, distance);
float randZ = Random.Range(-1 * distance, distance);
Target = new Vector3(randX, randY, randZ);
yield return new WaitForSeconds(time);
}
}
}