Novice/starting coder seeks help. I need to pass a variable from one scene to the next for player selection. This loads first:
var hit : RaycastHit;
private static var characterSelected:gameObject;
function Update () {
// Use Raycast to pick objects that have mesh colliders attached.
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Input.GetMouseButtonUp (0)) //Returns true during the frame the user deselects the object
{
if (Physics.Raycast (ray, hit, 100))
{
characterSelected:gameObject=playerAggy; //this doesn't work
Application.LoadLevel (1);
}
}
else {
}
}
That code is going to be a component of an invisible box collider (used to detect mouse click) on each 3D player in the level selection screen . Right now for testing, I only have it on the first player(Aggy). ("playerAggy" is the name of the prefab for the player (one of three.) )
In the second scene, I try to instantiate aggy to start gameplay like this:
function Start()
{Instantiate(characterSelected, transform.position, transform.rotation);}
My basic question is how do I say characterSelected=me and then pass characterSelected to following scenes.
Any help appreciated.