- Home /
Game objects created in scene but not game.
Hello, I followed a tutorial where a game object was created at 3 locations. Each location was selected randomly after some time interval. My problem is that after the time interval the game object does appear in the scene view but not in the game view. Please help. This is the code I am using.
public Transform prefab;
private float timer = 0;
private bool spawning;
private Transform loc;
void Start () {
GameEventManager.GameOver += GameOver;
}
void Update()
{
if (!spawning) {
timer += Time.deltaTime;
print(timer);
}
if(timer>=8)
{
Spawn();
print ("Spawn");
}
}
void Spawn ()
{
spawning = true;
int randompick = Random.Range (1, 3);
Transform loc;
if (randompick == 1) {
transform.Translate(5f, 2f, 0f);
Instantiate (prefab, transform.position, Quaternion.identity);
print("Position1");
}
if (randompick == 2) {
transform.Translate(10f , 2f, 0f);
Instantiate(prefab, transform.position, Quaternion.identity);
print("Position2");
}
if (randompick == 3) {
transform.Translate(15f , 2f, 0f);
Instantiate (prefab, transform.position, Quaternion.identity);
print("Position3");
}
timer = 0;
spawning = false;
}
}
Answer by Kiwasi · Jul 07, 2014 at 07:52 PM
A few possibilities
The renderer is turned off on the new GameObjects
The new GameObject is outside of the camera range
The new GameObject is in an unlit area of the scene
Answer by XxRQxX · Apr 16, 2015 at 02:13 AM
If this is 2D- make sure the child object has same Z value as parent.
Your answer
Follow this Question
Related Questions
instantiated two characters, but they only appear in scene mode. 0 Answers
Sprite Manager sprite is visible in Scene view but not Game view 0 Answers
Why do mobile particle shaders look bad in game view but not in scene view? 1 Answer
How to make mesh look normal in game mode 2 Answers
Positions of the objects in scene view and game view not the same. 1 Answer