Why is my Player slowing down between two Tilemap Colliders?
Hi Guys,
I am currently working on a 2D sidescrolling action game - I've come pretty far, but i am currently stuck at a strange problem. When the player crouches I am changing from a Box-Collider2D (the size of the Player) to a certainly smaller Circle-Collider2D (the size of the Head). I am doing this change so the player can move on narrow paths that normally are too low. (I've provided a screenshot below) Now heres the actual problem with that: Somehow i am colliding with a collider (i am asuming the tilemap collider), which makes the player slow down. - but why?
I've already added a PhysicsMaterial with Friction = 0 to both colliders of the player. I am moving the player based on calcuating the velocity trough keyboard input and then applying that velocity to the rigidBody of the player with Vector3.SmoothDamp. With no Tilemap-Collider above the player everything works fine, so i dont see where the problem is.
Does somebody have an ideo what the problem is or what I am doing wrong? :D
Thanks in advance!
Erik
Answer by ricolini · Feb 10, 2021 at 12:46 PM
Lessons learned: Never ever use two colliders on the same objects and use Collider2D.enabled to switch between them - instead create a new Collider each time with AddComponent and change the values of the collider.
Your answer
Follow this Question
Related Questions
What can I do to fix it? (Polygon Collisor shape equals shape sprite) 0 Answers
How do you deactivate a collider/gameobject for one player in a 2-player game with a button? 0 Answers
I cant get Unity Colliers to work!!! 2 Answers
No overload for method. (Question) 0 Answers
crouch attack collider 2d question 1 Answer