- Home /
Question by
danam · Mar 10 at 06:49 AM ·
colliders2d sprites
Can a sprite with a Dynamic 2D RigidBody detect a collision with a static 2D rigidBody?
I'm making a pinball machine. I have pin prefabs throughout: 2D sprites with static rigidbody2D components and CircleCollider2D components. The ball is a sprite with a Dynamic RigidBody2D and a CircleCollider2D. I have a script attached to the ball with the following code:
public void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "pin")
{
Debug.Log("Pin Hit!");
}
}
I have also tried OnCollisionEnter2D, but nothing responds... what am I doing wrong?
Comment