Question by
spykid202 · May 13, 2019 at 10:39 AM ·
spawningvisibilityspawnpoints
Can see objects from spawn points in scene view, but not in game.
Hello, I'm pretty new to unity and have been having some trouble regarding the visibility of objects spawned from certain spawnpoints. I can see them in scene mode, but not in game. I made sure the spawnpoints had a Z position value greater than that of the camera and that all layers were visible. Is there anything else I can check? Here' s the code in case the problem is in there:
using UnityEngine;
public class MeteorSpawner : MonoBehaviour
{
public GameObject meteor;
[SerializeField]
public Transform[] SpawnPoints;
[SerializeField]
public float SpawnDelay = .2f;
float NextTimeToSpawn = 0f;
void Update()
{
if (NextTimeToSpawn <= Time.time)
{
Spawnmeteor();
NextTimeToSpawn = NextTimeToSpawn + SpawnDelay;
}
}
void Spawnmeteor()
{
int RandomIndex = Random.Range(0, SpawnPoints.Length);
Transform Spawnpoint = SpawnPoints[RandomIndex];
GameObject Clone = Instantiate(meteor, Spawnpoint.position, Spawnpoint.rotation);
Destroy(Clone, 2);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612201255im_/https://answers.unity.com/themes/thub/images/avi.jpg)