Hello Guest

Author Topic: OnCollisionEnter2D and TileMap problem  (Read 3985 times)

G4L23

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
OnCollisionEnter2D and TileMap problem
« on: January 19, 2014, 08:56:32 pm »
Alright, so I've been converting my project from using 3D colliders to 2D colliders and have run into a strange issue.

I have a basic tilemap painted with a tag called Ground that uses the 2D edge colliders when the game is run. The player character has a 2D rigidbody and a 2D box collider on it, and in the player's script I have the following collision code -

Code: [Select]
void onCollisionEnter2D(Collision2D collision)
{
if(collision.collider.tag == "Ground") _isGrounded = true;
        print("COLLISION DETECTED");
}

void onCollisionExit2D(Collision2D collision)
{
if(collision.collider.tag == "Ground") _isGrounded = false;
}

When the player character collides with the tilemap, it works as expected and I can move the player around with no problem. But no matter what I do it will not detect the collision and change _isGrounded to true or print out any values. I never had a problem getting this working with the 3D colliders...

Am I missing something?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: OnCollisionEnter2D and TileMap problem
« Reply #1 on: January 20, 2014, 12:08:23 pm »
Your onCollision*** has a lowercase o? The function should start with O

G4L23

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: OnCollisionEnter2D and TileMap problem
« Reply #2 on: January 20, 2014, 05:16:09 pm »
And of course it was a stupid mistake ::) I retyped this portion from scratch and completely missed that. Thanks!