一个简单的脚本做一件简单的事情。然而,无论如何我都无法让它脚本工作。
using UnityEngine;
using System.Collections;
public class ShotScript : MonoBehaviour {
public Player pScript;
private Rigidbody2D shotRigid;
public bool enemyContact = false;
public bool enemyContactTrue = false;
void Awake() {
shotRigid = GetComponent<Rigidbody2D> ();
}
void Start() {
shotRigid = GetComponent<Rigidbody2D> ();
}
void enemyContactFunction() {
enemyContact = true;
}
void OnCollisionEnter2D (Collision2D col) {
if (col.gameObject.tag == "Enemy1" ) {
Debug.Log ("shot has collided with tagged enemy");
if (enemyContact == false){
enemyContactFunction();
}
}
}
}
调试会消失,但游戏中什么都没有发生,这需要我几天时间才能弄清楚。在像这样的碰撞之后,如果我的没有,其他人怎么会做出什么事情,发生什么事情呢?