- Home /
Player gets stuck when using precise collision shapes
Hi all,
I have some very precise shapes in my 2D tileset that my player has to walk around. I've made the custom physics shape for these tiles match the outline of these shapes in the sprite editor so the collision can be as accurate as possible.
However, my issue is that the player is getting stuck very easy when walking around and in between these shapes on the map.
I could probably solve this by smoothing out the collision outline shape, but because my shapes are very precise, the collision won't be as accurate. So I'm not sure I like that idea.
Are there any other ways I could overcome this? I've been messing about with physics materials to see if I can add something that makes the player walk across without getting stuck so easily. Adding bounciness is one I tried which kind of works but I'm not sure I like the jitteriness effect that adds. Anyone know of anything?
Could you post a few images of the colliders and what happens? :)
Answer by CoughE · Sep 02, 2021 at 03:01 PM
Usually collision shapes in video games are simpler and smoother than the geometry (in this case tiles) they are assigned too for this very reason. If the player is walking a surface that has lots of tiny rock graphics on it, they want to smoothly glide across rather than bump up and down and have to jump over each tiny rock.
Yes, it's like if you use pixel perfect graphics, a diagonal line turns into a staircase... You need to smooth it out into a moving-direction, and also have a reasonable transition to all other tiles it may connect to.
Answer by ahsen35813 · Sep 05, 2021 at 02:53 PM
I'm not sure how complex your collision shapes are, but perhaps you can try using circle colliders to match bumps instead of an actual mesh, which might reduce how much your player gets stuck. Another important thing for us to know is what kind of player do you have? Is it physics based or a custom player movement implementation? Physics based might allow it to bounce over things instead of getting stuck, even without bounciness.
Your answer
Follow this Question
Related Questions
Stuck Between tilemap colliders 0 Answers
When my character walks left and right on a tile map, the value of rb.velocity.y is often not zero. 0 Answers
Composite Collider on Tilemap not really stopping player 0 Answers
How do I know if collision is from right or left when using a Tilemap Collider 2D 0 Answers
2D Tilemaps: how to set colliders on scriptable tiles derived from Tilebase class 1 Answer