Question by
$$anonymous$$ · Dec 29, 2015 at 03:40 PM ·
2d gamerigidbody2dpolygon collider 2dignorecollisionphisics
Physics.IgnoreCollision between rigidebody2d+polygone collider 2d and edge collider 2d doesn't work?
Hi, I'm new at Unity. And I try to ignore collision between my gamer(rigidebody+polygone collider 2d) and a simple edge collider 2d. I've try to put this code in my gamer and the bullet is the edge collider. I've try in the other side too but it's doesn't work... do you know what I've doing wrong?
public class ExampleClass : MonoBehaviour { public Transform bulletPrefab; void Start() { Transform bullet = Instantiate(bulletPrefab) as Transform; Physics.IgnoreCollision(bullet.GetComponent(), GetComponent()); } }
Comment
Answer by MelvMay · Dec 29, 2015 at 04:49 PM
You're using 3D physics when you should be using 2D physics therefore, if you really want 2D then you should be using Physics2D.IgnoreCollision.