-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个新的公共变量一对一关闭和玩它我需要 –