So I’ve followed a tutorial on making an infinite runner to sharpen my 2D skills a bit. If anyone is curious about that, here’s a link:
Now during the video at a certain point you make a quad, and then you put a 2D collision box on it. You make it a trigger and then write a script that anything that hits the box gets destroyed so your game stays clean and whatnot. Problem is my boxes don’t do it at all. The script is attached to the quads, the quads are following the camera, but nothing that hits them seems to be destroyed.
Here’s my destroyerscript if anyone might be able to spot what’s wrong here =/
using UnityEngine;
using System.Collections;
public class DestroyerScript : MonoBehaviour {
void onTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
Application.LoadLevel(1);
return;
}
if (other.gameObject.transform.parent)
{
Destroy (other.gameObject.transform.parent.gameObject);
}
else
{
Destroy (other.gameObject);
}
}
}