Question by
Danief_ · May 13, 2019 at 06:38 PM ·
collisioncollider 2d
Collision2D Points Outside of Collider Bounds
Hi there, I'm trying to detect the points at which two collider2Ds collide. My problem so far can be seen in this video showing the error.
The white line traces the points where the collisions are currently being detected. Why are the detection points appearing outside of the bounds of my colliders?
The code:
void Start()
{
cp2 = new ContactPoint2D[5];
bc = GetComponent<BoxCollider2D>();
}
void OnCollisionStay2D(Collision2D col)
{
bc.GetContacts(cp2);
foreach (ContactPoint2D cp in cp2)
{
Instantiate(circle, new Vector3(cp.point.x, cp.point.y), Quaternion.identity);
}
}
Comment
Your answer
Follow this Question
Related Questions
How do you detect a mouse button click on a Game Object? C# 2 Answers
Destroying GameObject on collision Problems (Begginer) 1 Answer
OnCollisionEnter2D is called after object was shifted 1 Answer
orbiting mouse controlled camera goes through terrain 0 Answers
Deleting an object from a list of objects from another script. 1 Answer