using UnityEngine;
using System.Collections;
public class Spawn_collision : MonoBehaviour{
public void OnCollisionEnter2D( Collision2D col){
if (col.gameObject.name == "item1") {
Debug.Log ("starting collision");
//add points for item1
} else if (col.gameObject.name == "item2") {
//add points for item2
} else if (col.gameObject.name == "item3") {
//add points for item3
} else if (col.gameObject.name == "name4") {
//add points for item4
}
}
}
i am using the above code to try detect 3 different items colliding with another 2d sprite, they are all 2d sprites yet they do not seem to collide. I have tried calling the class from start and making a overflow method and it just ran the overflow method and not this one. I need some help on how to call this method from the start method or on a different way to do this.
Also will, col.GameObject.name even work with a sprite
what would you like a screen shot off and i have tried a debug.log in it and it never got printed but when i try call the method it goes on about an overflow method and when i create an overflow method it just runs that method
I’d just like to see the scene and one of those instances focused in the inspector…they r all the same, right?
So, the OnCollisionEnter2D is not triggered? …something must be wrong with the gameObject setup then. Screenshot would help. The objects are not kinematic, are they?