那是 Unity3D js 脚本错误,在 pc 上它工作正常,但如果我尝试将平台切换到 android...
触发器脚本:
#pragma strict
var P : GameObject;
var P_script;
var P_objname = "Player";
var P_script_name = "Player_script";
function Start() {
P = GameObject.Find(P_objname);
P_script = P.GetComponent(P_script_name);
}
function OnTriggerEnter(collider : Collider) {
if(collider.gameObject.name == P_objname) P_script.collision = true;
}
和 Player_Script :
#pragma strict
var collision : boolean;
var respawn_position : Vector3;
var respawn_time : int = 1;
var respawn_objname = "Respawn";
function Update () {
if(collision) {
Respawn();
}
}
function Respawn() {
renderer.enabled = false;
respawn_position = GameObject.Find(respawn_objname).transform.position;
gameObject.transform.position = respawn_position;
yield WaitForSeconds(respawn_time);
renderer.enabled = true;
collision = false;
}
请帮帮我:O