Hello, I’m pretty sure I’ve done everything right to make my objects collide but they dont! My Project is a 2d project and has 2d mode on My games is where i have the player in the middle of the screen and enemies come at him. I have a shield thats moves when you touch a side of the screen. I want it so the enemies collide with the shield and explode (destroy).The enemies are instantiated so i added this script onto the enemy:
void OnCollisionEnter2D (Collision2D col)
{
//Check collision name
Debug.Log("collision name = " + col.gameObject.name);
if(col.gameObject.name == "Shield")
{
Destroy(this.gameObject);
}
}
}
And i put 2d ridgidbody’s and 2d box colliders on the enemies and the shield. The ridgidbody’s are not kinematic, the gravity is just turned off. If this is just a bug in Unity then should I restart the project? Any help is greatly appreciated! Thanks!