2D Toolkit Forum

2D Toolkit => Support => Topic started by: G4L23 on January 19, 2014, 08:56:32 pm

Title: OnCollisionEnter2D and TileMap problem
Post by: G4L23 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?
Title: Re: OnCollisionEnter2D and TileMap problem
Post by: unikronsoftware on January 20, 2014, 12:08:23 pm
Your onCollision*** has a lowercase o? The function should start with O
Title: Re: OnCollisionEnter2D and TileMap problem
Post by: G4L23 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!