Generation

generate functionTue, 03 Jan 2023

make a monster randomly move throughout an area every 5 seconds

void Movement() { posX = Random.Range(0, 10); posY = Random.Range(0, 10); posZ = Random.Range(0, 10); } IEnumerator MovementLoop() { while (true) { Movement(); yield return new WaitForSeconds(5); // wait 5 seconds } } void Start() { StartCoroutine(MovementLoop()); }

Questions about programming?Chat with your personal AI assistant