Hi!
I’m making a 2D game where you are a space ship dodging asteroids. The asteroids and space ship are just rectangles at the moment so i use BoxCollider2D for both of them. I tag the astroid as “Asteroid” and the player space ship as “Player”. I then make 2 scripts. The problem is that nothing happens when the two objects are supposed to collide.
PlayerCollision:
function Start () {
}
function Update () {
}
function OnCollisionEnter2D(coll: Collision2D){
if(coll.gameObject.tag=="Asteroid"){
Destroy(gameObject);
}
}
AsteroidCollision:
function Start () {
}
function Update () {
}
function OnCollisionEnter2D(coll: Collision2D){
if(coll.gameObject.tag=="Player"){
Application.LoadLevel(Application.loadedLevel);
Destroy(gameObject);
}