本文介绍了OnCollisionEnter不团结叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我几乎每天检查答案对于这一点,但这些大多是简单的错误和失误。
我的问题是碰撞蒙山其他刚体时OnCollisionEnter不叫连
I checked nearly every answer for this, but those were mostly simple errors and mistakes.My problem is that OnCollisionEnter is not called even when colliding whith other rigidbody.
这里是不会被调用的部分:
here is the part what does not get called:
void OnCollisionEnter(UnityEngine.Collision col) {
Debug.Log("collision!!!");
foreach(ContactPoint contact in col.contacts) {
//checking the individual collisions
if(contact.Equals(this.target))
{
if(!attacking) {
Debug.Log("hitting target");
} else {
Debug.Log("dying");
//engage death sequence
}
}
}
}
甚至没有了碰撞!!!消息出现。难道我理解错了的用法,还是我忘了什么东西?
Not even the "collision!!!" message appears. Do I understand the usage wrong, or did I forget something?
推荐答案
??。如果是这样使用此功能,而不是 OnCollisionEnter
Are you using 2D colliders and rigidbodies ??. If so use this function instead of OnCollisionEnter
void OnCollisionEnter2D(Collision2D coll)
{
Debug.Log(coll.gameObject.tag);
}
这篇关于OnCollisionEnter不团结叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!