I have this 3D game about a ball bouncing up and down, and it’s supposed to avoid sharp objects. I’m a Unity noob and would like to know if it’s possible to repeat:
-make multiple objects at different heights
-have them fly across the screen, and
-have them reappear at different heights
I know it sounds like hell but I can’t find anything on YouTube so im stuck with this post.
Just so happens I needed a similar code. Here,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnerScript : MonoBehaviour
{
public GameObject Ball;
float delay;
// Start is called before the first frame update
void Start()
{
delay = Random.Range(1f, 3f);
StartCoroutine(Spawner(delay));
}
IEnumerator Spawner(float d)
{
yield return new WaitForSeconds(d);
InstantiateBall, transform.position, transform.rotation);
delay = Random.Range(0.001f, 0.1f);
StartCoroutine(Spawner(d));
}
}