-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);
}
당신은 그쪽을 깨닫습니다. t 문에서 if 문에서 IsColliderEnabled의 값을 1로 설정하고 1 ... right와 같으면 테스트하지 않습니까? – Alox
예 마지막으로 몇 가지 변경 사항을 작성하고 두 가지 새로운 변수를 사용하고 변경하려면 wen은 0부터 1까지 필요합니다. 코드를 테스트했지만 테스트하지 않은 상태에서 최종 결과를 모두 알게됩니다. 그리고 아니요. 게임 관리자를 사용하지 않았습니다. 저는 다른 코드의 개발자이고, 몇 주 전에 js와 C#으로 시작합니다. –
그리고 그게 내 힘든, 그것을 비교하는 방법을 모르겠다, 그래서 내가 2 개의 새로운 공개 변수 하나 하나를 위해 그것을 결정하고 그것을 원한다면 원한다면 원한다. –