- Home /
Tilemap collider 2D problem.
I have a simple Grid with 2 Tilemaps(one for the ground and one for the walls). My player has a rigidbody2D and moves by changing the value of its velocity. I also have added a Tilemap Collider 2D on the wall Tilemap. Problem is: at certain points of the wall, when running from one edge of the grid to the other, the player goes through the collider or does a bit of a bounce back(Photos below for the grid and the player movement).
Good day.
I do not have the answer to your question, i never used colliders for preventing movement.
If you will use the wall tilemap only as a rectange to prevent player go outside the grid, you can simply prevent the position of the player to overpass some limits.
if (player.transform.position.x > 150)
{
player.transform.position = new Vector3 (150, player.transform.position.y, 0)
}
Something like this. This consume less CPU, because do not need to check for collisions.
Bye!
Yeah, but what if I have more objects in the room(tables, chairs etc) or differently shaped walls? How can I prevent movement in these situations without colliders?
Your answer
Follow this Question
Related Questions
Stray tilemap collider being weird, won't erase 4 Answers
Why are tilemaps so bad ? 2 Answers
The tilemap collider is simply not working 0 Answers
Modular Room System Similar to Mega Man 0 Answers
Tilemap collider doesn't appear 1 Answer