- Home /
Question by
heitaoflower · Jan 12, 2016 at 10:03 AM ·
rigidbody2dphysics2dboxcollider2d
Why collision2d happend earlier in rigidboy2d?
In the case of a collision between a tank and an obstacle, there is no contact, but a collision2d happend, and what is the reason?
how to avoid it ? PLZ
qq截图20160112161210.png
(286.5 kB)
Comment
Best Answer
Answer by heitaoflower · Jan 12, 2016 at 04:58 PM
ok, I will try ,thanks a lot. There is a paper talk about this situaion,just share it.
Answer by lassade · Jan 12, 2016 at 01:51 PM
I made some test,
This happens if the Rigidbody2D.collisionDetectionMode is in Continious mode change it back to Discrete.
Edit: You can use this code to debug, it will pause the game at collision.
using UnityEngine;
using System.Collections;
public class PauseOnTouch : MonoBehaviour {
void OnCollisionEnter(Collision collision)
{
Debug.Log(System.String.Format("Recived {1} [OnCollisionEnter] from {0}", collision.collider.name, name));
Pause();
}
void OnCollisionEnter2D(Collision2D collision)
{
Debug.Log(System.String.Format("Recived {1} [OnCollisionEnter2D] from {0}", collision.collider.name, name));
Pause();
}
static void Pause()
{
//Debug.DebugBreak();
Debug.Break();
}
}