- Home /
Two Different Box Colliders Aren't Colliding
I've taken a little break from a project, but have recently updated to Unity 5.3.5 from 5.3.3 (Interestingly It had some kind of warning about updating - I can't remember what it was specifically).
Onto the problem, I created an empty game object with a box collider2D and put a script on it to destroy game objects. This works beautifully on all colliders that have been in the project before the update, but when I create a new object with a box collider2D on it - it doesn't collide at all! It doesn't even recognize that it's colliding. Yes I have checked the collision matrix as well, and it's working as expected.
Here is the destroyer collider's script (that destroys the out of bound objects):
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
public class Destroyer : MonoBehaviour
{
int deathTime = 1;
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
StartCoroutine(DeathAfterSec(deathTime));
}
Destroy(collision.gameObject);
if(collision.gameObject.tag == "Untagged")
{
Debug.Log("planksucks");
}
}
IEnumerator DeathAfterSec (int deathTime)
{
yield return new WaitForSeconds(deathTime);
SceneManager.LoadScene("Scene2");
}
}
Yes - I am trying to destroy the object named Plank ;p
Answer by laszlar · Jun 02, 2016 at 04:02 AM
I found the answer from another question that was slightly different. It's a Unity bug, and the solution is to add a rigidbody2d to the object your trying to destroy and enable kinematic.
For those interested: http://forum.unity3d.com/threads/unity-2d-trigger-box-colliders-not-working-on-5-3.372615/
I'm not sure if the "bug" is fixed yet (or reappeared in recent versions). But the main idea is to NEVER move a static object.
@allenallenallen ugghh I'm pretty sure I sound like a noob, but static object? The original box collider is static, and doesn't move. The second object co$$anonymous$$g towards it is a box collider, the first object (static) sits there and when second object comes up to it, the first object destroys the second object.
Your answer
![](https://koobas.hobune.stream/wayback/20220612082115im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Collision detection problem 0 Answers
Object passes through collider even when isTrigger is turned off. 2 Answers
Having problems with obstacle collision killing the player 1 Answer
OnCollisionExit2D workaround? 0 Answers
How do I set an object's velocity to the velocity of an object that collided with it? 0 Answers