My OnTriggerEnter destruction script won't trigger
Okay, so I'm making an arcade style game where you are shooting flying enemies. However, the script responsible for destroying the necessary objects doesn't appear to be activating. It looks something like this:
#pragma strict
function OnTriggerEnter ()
{
Debug.Log("Destroyed");
Destroy(gameObject);
}
This script is on everything that needs to be destroyed at the moment, including the bullets, the player, and the enemies. I have 2D box colliders on all of these. The ones on the bullets have "Is Trigger" selected. The player and the enemies have two colliders, one without "Is Trigger" and one with "Is Trigger" for each. The Debug.Log has not been triggering at all. I am almost certain that this is something simple that I am overlooking, because I haven't coded in a while.
Feel free to ask for any additional information that you feel is necessary. I really can't figure this out.
Answer by doublemax · Nov 03, 2016 at 01:37 AM
If you're using 2D colliders, you must use OnTriggerEnter2D
https://docs.unity3d.com/550/Documentation/ScriptReference/Collider2D.OnTriggerEnter2D.html