Hello Guest

Author Topic: Collision Issues  (Read 4415 times)

pablopun ch

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Collision Issues
« 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");
}
}

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Collision Issues
« Reply #1 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?

pablopun ch

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Collision Issues
« Reply #2 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

Tiltgames

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Collision Issues
« Reply #3 on: December 17, 2013, 06:55:02 am »
Just a guess: Do you use 2d colliders? Then it's OnTriggerEnter2D...