- Home /
Question by
jayesh4520 · Jan 01, 2018 at 01:00 PM ·
2dinstantiaterandom2d-platformerspawning
script not working pls solve it
using UnityEngine;
public class BlockSpawner : MonoBehaviour {
public Transform[] spawnPoints;
public GameObject u;
public float timeBetweenWaves = 1f;
private float timeToSpawn = 2f;
void Update () {
if (Time.time >= timeToSpawn)
{
SpawnBlocks();
timeToSpawn = Time.time + timeBetweenWaves;
}
}
void SpawnBlocks ()
{
for (int i = 0; i < spawnPoints.Length; i++)
{
{
Instantiate(u, spawnPoints[i].position, Quaternion.identity);
}
}
}
}
after one second nothing instantiate
Comment
Is it that you don't see in GameView that no objects are spawning, or do you also check the Hierarchy in Play mode, and no new GameObjects get added?
Answer by dev-waqas · Jan 01, 2018 at 01:51 PM
There can be many reasons. Here are some suggestions.
1) Check you are correctly assigning GameObject u.
2)Check time scale of your game might be 0. Set it like this.
void Start() { Time.timeScale = 1; }
Your answer
Follow this Question
Related Questions
Instantiate random object from Array 2 Answers
Random Terrain in 2d Game? 0 Answers
After picking up an object, spawn a new one in a random location 1 Answer
Random Spawning system? 1 Answer
General pooling question 1 Answer