-2
我有2個腳本,我嘗試做一個觸發器的第一個腳本來啓用其他腳本觸發器,我試圖調查,但我仍然堅持我的代碼。啓用onCollition輸入一個變量
我的第一個代碼是
using UnityEngine;
using System.Collections;
public class endpoint10 : MonoBehaviour {
public static int IsColliderEnabled;
endpoint10.IsColliderEnabled = 0;
void OnTriggerEnter(Collider other)
{
if (IsColliderEnabled = 1) {
//do stuff here
// The switch statement checks what tag the other gameobject is, and reacts accordingly.
switch (other.gameObject.tag) {
case "end":
Debug.Log (other.gameObject.tag);
PlayerPrefs.SetInt ("moneyPref", scoreManager.money);
PlayerPrefs.SetInt ("scorePref", scoreManager.score);
ScoreSystem.level += 1;
PlayerPrefs.SetInt ("levelPref", ScoreSystem.level);
Debug.Log ("values stored");
Application.LoadLevel ("level_11");
break;
}
}
// Finally, this line destroys the gameObject the player collided with.
//Destroy(other.gameObject);
}
}
和我的第二個代碼
using UnityEngine;
using System.Collections;
public class trigguercubex : MonoBehaviour {
public GameObject[] objects;
void OnTriggerEnter(Collider other)
{
endpoint10.IsColliderEnabled = 1;
Debug.Log (other.gameObject.tag);
}
// Finally, this line destroys the gameObject the player collided with.
//Destroy(other.gameObject);
}
你確實意識到t在你的if語句中,你將IsColliderEnabled的值設置爲1,而不是測試它是否等於1 ...正確? – Alox
是finaly我已經做了一些改變,並使用兩個更多的新變量,並改變他們我需要0到一個我已經測試代碼withh沒有erros,但我沒有測試,但最終的結果,我會讓所有人知道它的最後。不,我沒有使用過遊戲管理器,我是其他代碼的開發人員,我幾個星期前就開始使用js和c#。 –
這就是我的困難,我不知道如何比較它,所以我決定讓2個新的公共變量一對一關閉和玩它我需要 –