2D Toolkit Forum

2D Toolkit => Support => Topic started by: pablopun ch on December 16, 2013, 08:39:35 am

Title: Collision Issues
Post by: pablopun ch on December 16, 2013, 08:39:35 am
So I am having this crazy issue. I am collecting coins in a platformer. The coins have a box collider that has isTrigger enabled/checked. This coin is an Animated Sprite that has a tag of coin. My player has a child gameObject that has a rididbody and capsule collider. In my player script I have the following:

Code: [Select]
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("coin")){
Debug.Log ("Hit");
}
}

What could I be doing wrong. This seems pretty straight forward. I just want to detect the collision in the console and move from there. I have also tried the following:

Code: [Select]
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "coin"){
Debug.Log ("Hit");
}
}
Title: Re: Collision Issues
Post by: unikronsoftware on December 16, 2013, 11:50:53 am
Does it ever call OnTriggerEnter? If it is, then you could print out other.gameObject.tag to see what its printing?
Title: Re: Collision Issues
Post by: pablopun ch on December 16, 2013, 02:36:59 pm
No it is never called. I have now tried checking the Is Kinematic on my rigidbody for the player. Still no luck
Title: Re: Collision Issues
Post by: Tiltgames on December 17, 2013, 06:55:02 am
Just a guess: Do you use 2d colliders? Then it's OnTriggerEnter2D...