Generation

generate functionTue, 28 Mar 2023

codigo para objetos caigan sucesivamente sin apretar un boton

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Spawner : MonoBehaviour { public GameObject[] obj; private int objIndex; public float timeLeft; public float timeBetween; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (timeLeft <= 0) { objIndex = Random.Range(0, obj.Length); Instantiate(obj[objIndex], transform.position, Quaternion.identity); timeLeft = timeBetween; } else { timeLeft -= Time.deltaTime; } } }

Questions about programming?Chat with your personal AI assistant