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");
}
}
↧