-2
私は2つのスクリプトを持っていますが、私は最初のスクリプトのトリガーを他のスクリプトのトリガーを有効にするようにしようとしています。変数でonCollitionEnterを有効にする
私の最初のコードは
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);
}
あなたはそれを実現するあなたのifステートメントでは、IsColliderEnabledの値を1に設定し、それが1 ... rightに等しいかどうかをテストしません。 – Alox
はい最終的に私はいくつかの変更を行い、さらに2つの新しい変数を使用し、それらを変更する必要があります0から1を必要とするコードをテストしたが、私はまだテストしませんでした。いいえ、私はゲームマネージャーを使用していません。私は他のコードの開発者です。私はちょうど数週間前にjsとc#で始まります。 –
そして、それは私の難しいことです、私はそれを比較する方法を知っているので、私は2つの新しい公共の変数を1つ1つをオフにしてそれを再生するためにそれを決定するwen私は必要とします –