- Home /
Question by
freakprince · Feb 08, 2013 at 09:33 PM ·
gameobjectscene-loadingontriggerstay
My script doesnt recognize my player
Hello folks i have this script that on trigger stay, enables/disables thirdpersocontroller script on button press, it seems not to work even tho i drag and drop my Player on the gameobject spot. My project is made of 2 scenes and my Player starts on scene 0 and then when i press "START GAME" he spawns on scene 1, so when i am on scene 1 and while playing my game i drag and drop Player again on the gameobject spot and that seems to work for my script, anyone know why this is happening?? this is the script:
var Player : GameObject;
function Start () {
}
function OnTriggerStay (other : Collider)
{
if(other.gameObject.tag == "Player"){
if(Input.GetKeyDown("2")) {
Player.GetComponent(ThirdPersonController).enabled = true;
}
}
else if(Input.GetKeyDown("3")) {
Player.GetComponent(ThirdPersonController).enabled = false;
}
}
Comment