My current script is a script for a door collision. when the Distance reaches less then 1 the player is moved to a separate scene and to the spawn point in which is specified in the code. I am currently having problems with the player not being found and when i just assign the player manually the send message script does not find the its way to parent in which the second script is attached. The game object Trigger which the first code is attached to is the child of the Spawnpoint in which the Second script is attached. Thanks in advance
this is my code:
var Player : Transform;
var Inside : float = 1;
var GoingToSpawnPNT : int = 0;
var Dist : float;
function Start()
{
Player = transform.Find("Player");
}
function Update()
{
if (Player != null)
{
var dist : float = Vector3.Distance(Player.position, transform.position);
Dist = dist;
if (dist < Inside)
{
Player = null;
transform.root.gameObject.SendMessage("Assign", GoingToSpawnPNT);
}
}
}
This is my Second code
var CustomSpawnPoint : int;
static var Spawn : int;
var Level : String;
function Update()
{
if (Spawn == CustomSpawnPoint)
{
Debug.Log("Spawned");
Spawn = 0;
//Create Character
}
}
function Assign(SpawnNum : int)
{
Spawn = SpawnNum;
Application.LoadLevel(Level);
}