Hi everyone!
Was wondering if anyone could help. I’m trying to create a scene where red blood cells are freely flowing through a vessel. Cells are moving towards a target offscreen and I would like this to continue throughout the scene.
Here is my script so far:
using UnityEngine;
using System.Collections;
public class Move : MonoBehaviour {
public GameObject gameObject;
public Transform Target;
public float speed = 10f;
public float time = 1f;
private IEnumerator Move()
{
while (true) {
float step = speed * Time.deltaTime;
gameObject.transform.position = Vector3.MoveTowards (transform.position, Target.position, step);
yield return new WaitForSeconds (time);
}
}
private void Update()
{
StartCoroutine(Move());
}
}
Any help is greatly appreciated!
Kearley x