Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

Spawn carachters on locations and destroy the manager after level load

$
0
0
How do I spawn my carachters to the coordinates 473 44 1213 Depending on the class it will spawn another carachter and later on destroy the manager object It's hard to explain Sorry for noobish question //The choose script #pragma strict var Spotlight : GameObject; var isClass1 : boolean = false; var isClass2 : boolean = false; var OtherOBJ : GameObject; function Start () { Spotlight.SetActive(false); } function OnMouseEnter () { Spotlight.SetActive(true); Debug.Log("Entered collider"); } function OnMouseExit () { Spotlight.SetActive(false); Debug.Log("Exited collider"); } function OnMouseUp () { Debug.Log("Clicked box"); Selected(); } function Selected() { if (isClass1 == true) { var script: Manager = OtherOBJ.GetComponent(Manager); script.spawnClass1 = true; } if (isClass2 == true) { script.spawnClass2 = true; } } //The manager script #pragma strict var spawnClass1 : boolean = false; var spawnClass2 : boolean = false; var Class1 : GameObject; var Class2 : GameObject; function Update() { if(spawnClass1 == true) { Debug.Log("Will Spawn 1"); LoadLevel(); } if(spawnClass2 == true) { Debug.Log("Will Spawn 2"); LoadLevel(); } } function LoadLevel() { DontDestroyOnLoad(gameObject); Application.LoadLevel(2); Spawn(); } function Spawn() { if(spawnClass1 == true) { Debug.Log("Spawned 1"); } if(spawnClass2 == true) { Debug.Log("Spawned 2"); } }

Viewing all articles
Browse latest Browse all 416

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>