Hello, unfortunately I didn’t find anything about my problem in the forum:
I’m looking for a way to change my scene in the game when something happens: e.g. if I killed enemy X, a tree / stone should spawn in place Y. Or the sky should change from blue to red.
I’ve been looking for a solution to this since yesterday, but I can’t think of anything proper to do …
Thanks for the ideas
You can try this:
public GameObject Bridge;
public GameObject Background1;
public GameObject Background2;
public void KillEnemy(){
Bridge.SetActive (true); //Active the bridge
Background1.SetActive (false); //Deactivate the actul background
Background2.SetActive (true); //Activate the new background
}
In case you want to spawn an object, and not activate or deactivate it, you must do this:
public GameObject Bridge; //Object from assets
public GameObject Background1; //Object from the scene
public GameObject Background2; //Object from assets
public void KillEnemy(){
Instantiate (Bridge);
Destroy (Background1);
Instantiate (Background2);
}