0
那Unity3D js腳本錯誤,在PC上它做工精細的一員,但如果我嘗試切換平臺到Android ...BCE0019:「碰撞」不是「對象」
Trigger_Script:
#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;
}
幫我PLZ:O型
我有測試這一點,但現在: NullReferenceException:未將對象引用設置爲對象的實例 Trigger_script.Start()(At Assets/Script/Trigger_script.js:8) #pragma strict var P_script:Player_script; var P_objname =「Player」; (){ function Start P_script = tmp.GetComponent(「Player_script」); P_script.collision = true; Debug.Log(「Current collision:」+ P_script.collision); } –
@RaffaeleElShaarawyIabichino'tmp.GetComponent(「Player_script」);'必須*完全匹配您的腳本的名稱。嘗試使用'tmp.GetComponent(「Player_Script」);'(注意大寫'S') – Jerdak
好吧我嘗試,並:NullReferenceException Player_script + $ Respawn $ 34 + $。MoveNext()(在Assets/Script/Player_script.js: 23) UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator) Player_script:Update()(在Assets/Script/Player_script.js:13),另一個錯誤:NullReferenceException:對象引用未設置爲對象的實例 Trigger_script.Start ()(在Assets/Script/Trigger_script.js:9)。 LoL現在?幫我看看.... –