This is one way to solve that, thanks for sharing. There's another way where you can still use circle or capsule colliders for your character if you like: For your tile sprites, open the Sprite Editor and customize the physics shape of your sprite (by clicking the "Sprite Editor" dropdown in the top left corner inside of the Sprite Editor. Doing that for the surface tiles (the ones, that the character walks on, shbould be enough in most cases. AFTERWARDS add the tilemap collider component. This way, not only those edgy gaps at the corners between tiles disappear int the tilemap collider, you can also define the size of the collider for your tiles precisely (on pixel level), which comes handy when the graphics are more like grass or something else not so obvious defined like your example in the video.
Haven't tested this myself but sounds reasonable. I'm pinning your comment, assuming your solution can help with not-so-obvious tile shapes like you pointed out (grass, etc...). Thanks for sharing.
I actually ran into this problem and the custom physics shape didn’t solve my problem. I still got stuck on corners. I had to also add a composite collider to the tilemap, which combines all the tile colliders into one continuous edge.
Bro! This is EXACTLY what I've been looking for! You just saved me SOO much frustration!!! Thank you so much! EDIT: I'm having the same issue as some others where my character gets stuck in the floor... EDIT2: Fixed it by changing the composite collider from outline to polygon.
I had to take a different solution for mine and couldn't rely on the composite collider method with a tilemap because I had to use multiple game objects with box colliders that could both be accessed and used as a ground layer in my 2D platformer object. But I managed to get around this problem by creating an edge collider for my player to go along with my box collider. Creating lil slopped edges that aren't even noticeable when passing by this bug :)
Who knew such a silly problem had the most simple solution, I was already planning on creating an entire system to generate meshes. Thank you very much!
When I found out my character was getting caught on stuff, including the edges, I was thinking, "What the hell is going on?" I tried your method. Worked *perfectly.*
It seems like you stopped making videos a long time ago, your tutorial was very useful, tomorrow is the end of the GMTK game jam and you just saved my project. If you see this, merci mreuf tu gères ;)
If you did this and still have the issue, just disable the TileMap collider and renable it and you will have it fixed. I'm glad that's the only very simple thing i have to do and not do a complicated thing to fix.
I know that this video is pretty old, but thank you so much for this useful information! I've been trying to fix this issue for a while now with no result. thanks for clearing this up :)
you're a bit quiet in this video but this helped a lot, the random jumps aren't the only problem with circle colliders, they cause problems when trying to jump at the edge as you slide off of them before you would with a box collider
Thank you very much for this video and thank you for clearly explaining what the problem was so people like me understood what was happening. I've been scratching my head on how to solve the stuck issue. Great job on your game as well! I would love it if you did a tutorial video on how you did the lights and shadows in your game (including how to detect if your player is in the light or not).
composite colliders have issues if your goal is to achieve procedural generation.. the larger the amount of colliders when loading or unloading chunks, the more it needs to compile the new geometry outcome
Not only this, using a composite collider 2d also helps with performance as it decreases the amount of colliders when tiles are grouped next to each other.
You can also fix it by decreasing the Default Contact Offset in Edit/Project Settings/Physics 2D Changing it from 0.01 to 0.0001 worked for me Source: th-cam.com/video/ntLDLYDsWAQ/w-d-xo.html
Hi, I'm having a bug that falls into a tiles and stuck in it when jumping from above high or sometimes just jumping normally but still has a similar problem. Do you have any way to fix it to guide me? My English is not good so I apologize if there is a grammar mistake
hi so I have a problem where everytime I make my character jump it, the character will bounced off to a random dirrection even if im not touching the move button. So when I hold my jump key it starts to slowly moves to the side. when I run and jump my character it boosted my character either backward or forward. I tried to expand the colider box but it didn't work. can you help me?
@@kiwisitooyt I kinda forgot but one of the thing I remmeber doing is instead of moving the character by modifying it's velocity, I move it by Vector2.Translate().
I tried this and it fixed the problem but caused all my particle effects and some other stuff with physics and gravity just fall through the tilemap, so instead I just left the tilemap as is and changed box collider to a capsule collider for the body and an edge collider on the bottom and that seems to work as well
when ı use composite collider on tilemap collider it become empty box so chacter have change to get inside tile map composite body if forced :( is here any one know a solvation ? ı want it behave like normal collider
This video was exactly what I was looking for, thank you! Edit 1: I've been continuously having a problem where the character now falls through the tiles, if going at high enough speeds. (I'm using a capsule collider 2D, with no friction on a 2D physics material.) got any solutions?
If you haven't already found a solution since it's been 2 weeks, I think the problem is that your using discrete collision detection. On your rigidbody, in collision detection, change it to continuous, because discrete checks it every frame, so you could be on one side of the floor one frame and the other side on the next frame.
oh wow just came here to say that I skipped making the rigidbody static and it fell off the screen which was hilarious, then I siad oh, I will just set gravity to zero. My whole fence moved when I ran into it. I fixed it now.
My problem is that composite colliders are prone to other rigidbodies getting stuck inside them. Still looking for a way to use boxcolliders on my tiles without getting the snag issue.
I never had a rigidbody stuck inside a composite collider, I'm curious in what situation does that happens to you? Do you work with high velocity objects? Depending on your use case you might be able to get away with limiting the velocity to a max speed through code. Something else I didn't mention in the video that you could try is to keep all tiles as box colliders and try to detect slopes ahead of your character in your character controller script using a raycast in the forward direction (or an equivalent Physics2D.OverlapCircle). If you detect an edge (which is just a very small slope) and your character is trying to move forward you can move the player on top of the slope. See an example here: gist.github.com/Garfounkel/be99b53f7ce62cf5d7653a4f9fcea331#file-charactercontroller2d_checkslope-cs
This is one way to solve that, thanks for sharing. There's another way where you can still use circle or capsule colliders for your character if you like:
For your tile sprites, open the Sprite Editor and customize the physics shape of your sprite (by clicking the "Sprite Editor" dropdown in the top left corner inside of the Sprite Editor. Doing that for the surface tiles (the ones, that the character walks on, shbould be enough in most cases. AFTERWARDS add the tilemap collider component.
This way, not only those edgy gaps at the corners between tiles disappear int the tilemap collider, you can also define the size of the collider for your tiles precisely (on pixel level), which comes handy when the graphics are more like grass or something else not so obvious defined like your example in the video.
Haven't tested this myself but sounds reasonable. I'm pinning your comment, assuming your solution can help with not-so-obvious tile shapes like you pointed out (grass, etc...). Thanks for sharing.
It really helped me, thanks!
I actually ran into this problem and the custom physics shape didn’t solve my problem. I still got stuck on corners. I had to also add a composite collider to the tilemap, which combines all the tile colliders into one continuous edge.
Thank you so much for this tutorial, I've been moving this fix for a long time now until I found this material. One more time, thank you.
Bro! This is EXACTLY what I've been looking for! You just saved me SOO much frustration!!! Thank you so much!
EDIT: I'm having the same issue as some others where my character gets stuck in the floor...
EDIT2: Fixed it by changing the composite collider from outline to polygon.
bro... us
thanks for this comment haha!!!
I had to take a different solution for mine and couldn't rely on the composite collider method with a tilemap because I had to use multiple game objects with box colliders that could both be accessed and used as a ground layer in my 2D platformer object.
But I managed to get around this problem by creating an edge collider for my player to go along with my box collider. Creating lil slopped edges that aren't even noticeable when passing by this bug :)
looks like this works
Who knew such a silly problem had the most simple solution, I was already planning on creating an entire system to generate meshes. Thank you very much!
Hours spent on forums to solve is problem, and you did it in a 5 minute video. Brilliant!
When I found out my character was getting caught on stuff, including the edges, I was thinking, "What the hell is going on?"
I tried your method.
Worked *perfectly.*
It seems like you stopped making videos a long time ago, your tutorial was very useful, tomorrow is the end of the GMTK game jam and you just saved my project. If you see this, merci mreuf tu gères ;)
Glad I could help with your GMTK project! If you want, reply with a link to your game jam project, I'm curious to check it out. De rien fréro
your video appears at the top of google search "tilemap stuck"
absolute legend
Great tutorial, well explained and not too long, thanks and keep it up!
As a game dev rookie, this saved my ass! Thank you!
Le petit accent Français qui ma donné le sourire pdt toute la vidéo, merci à toi btw ;).
Holy crap YESS!! And you can use Effector component as well if you mark "Used by effector" in the Composite.
This bug has been plaguing me for years, thank god i found this video
Can't help but comment on such a helpful video, every forum just didn't help at all.
Thank you very much!! You probably saved me a few hours and some mental breakdowns
Thanks man! I was stressed about this problem and I knew that changing the character's collider was the wrong way! thanks for existing
Glad I could help :)
This helped thanks. I was individually placing the box colliders on platforms until now, so thanks!
If you did this and still have the issue, just disable the TileMap collider and renable it and you will have it fixed. I'm glad that's the only very simple thing i have to do and not do a complicated thing to fix.
THANK YOU SO MUCH! I was getting frustrated that it didn't work but this was such an easy fix!
Thank you for helping me save my time and my nerve cells.
I hardly do any comment on any video ,
You are the best
thank you, i was worried f i coldn't solve my problem. your solution works for me, great video.
GOD BLESS YOU, GOD BLESS YOUR FAMILY, GOD BLESS YOUR YEAR, GOD BLESS YOUR LIFE
I've been looking for this for an hour! Thank you!
Thanks for making this, I was trying to root around my code trying to fix the issue. Super helpful
excellent :D, good graphical explanation, nice presentation, and good knowledge, keep it up you deserve more subs!
Thanks! That's really nice of you :)
Absolutely fantastic video, great stuff!
Omg , Thank you so much. I have had this progmlem for days and could find out what was wrong with my Tilemap nor could find any solutions online.
Thank you so much man. Great tutorial. i was having this problem for a few days now. Glad I found this tutorial.
Straight to the point and well explained. Very useful content, you just saved me a lot of headaches!
I know that this video is pretty old, but thank you so much for this useful information! I've been trying to fix this issue for a while now with no result. thanks for clearing this up :)
Lifesaver my guy!
you're a bit quiet in this video
but this helped a lot, the random jumps aren't the only problem with circle colliders, they cause problems when trying to jump at the edge as you slide off of them before you would with a box collider
Bit quiet? I can perfectly hear him with volume of just 5/30
What if it's a 3d game with cubes
thanks man, hi from brazil
What if I'd like to generate a composite collider **3D** instead?
Thank you very much for this video and thank you for clearly explaining what the problem was so people like me understood what was happening. I've been scratching my head on how to solve the stuck issue. Great job on your game as well! I would love it if you did a tutorial video on how you did the lights and shadows in your game (including how to detect if your player is in the light or not).
Merci beaucoup mon ami , a very smooth tutorial with a beautiful accent. I really hope you make more tutorials like this in the future.
De rien! :) I'm glad I could help
This is exactly what I've been looking for. That's very helpful. Thankyou.
This is awesome. Thank you for this explanation. Such a frustrating problem and such a simple solution.
thanks man! really huge help! I would have spent a lot of time finding this out.
composite colliders have issues if your goal is to achieve procedural generation.. the larger the amount of colliders when loading or unloading chunks, the more it needs to compile the new geometry outcome
thank you so much you help me with this tutorial , and i hope to make another tutorial about how fix the same problem without tilemaps
I'm having an issue where I have a character with a rounded collider hit the corner of a block and get stuck in it, how do I fix that?
Not only this, using a composite collider 2d also helps with performance as it decreases the amount of colliders when tiles are grouped next to each other.
Exactly what I needed. Thanks!
Thank you so much. You save my life!!!!! Apprecciate your work! I'll give you like
My charecter strucks in walls when i jump how to fix it
Change the composite collider from outline to polygon.
That is fixed already thanks for your advice i did what you said in the video
very good video. was trying to fix it myself and couldnt figure it out for the life of me. Thanks :D
Nice explanation and solution.
so very helpful, thanks man!
You can also fix it by decreasing the Default Contact Offset in Edit/Project Settings/Physics 2D
Changing it from 0.01 to 0.0001 worked for me
Source: th-cam.com/video/ntLDLYDsWAQ/w-d-xo.html
Great video!
How could I do this for 3D?
Thanks so much!!! Been struggling with it a lot and this helped :D👌
This was exactly my problem. Thank youuy
I DID NOT KNEW THAT COMPOSITES COLLIDERS COULD DO THAT!!!1 That was AWESOME
Does it also work with 3D Colliders?
When i use Composite my character can go into textures. So i dont know how to fix it :/
thanks a lot, super concise video
Thank you so much bro I was crying for 10 hours trying to fix it! You saved my life, I almost committed suicide. Deserve a sub
( ̄︶ ̄)↗
Lol. Happy I could help
Thank you for your advice, it's help me a lot of.
Yo, how did you detect light in your game, was it with raycasts?
this is a godsend
thanks so much man, this helped a ton
that is what i was looking for! Thanks
How to solve similar issue in 3d game tiles?
Thanks pal, i knew there was a way to do this but id forgotten
Hi, I'm having a bug that falls into a tiles and stuck in it when jumping from above high or sometimes just jumping normally but still has a similar problem. Do you have any way to fix it to guide me?
My English is not good so I apologize if there is a grammar mistake
absolument parfait, merci beaucoup
😊Thanks Buddy! You are very helped me!
Thanks Again!😊
Helped my issue perfectly
i actually thought it was because of the weird tile i've made lmao that helped me so much
thank you so much your such a life saver!
hi so I have a problem where everytime I make my character jump it, the character will bounced off to a random dirrection even if im not touching the move button. So when I hold my jump key it starts to slowly moves to the side. when I run and jump my character it boosted my character either backward or forward.
I tried to expand the colider box but it didn't work. can you help me?
Same for me. Did you solve it??
@@kiwisitooyt I kinda forgot but one of the thing I remmeber doing is instead of moving the character by modifying it's velocity, I move it by Vector2.Translate().
Really great Video Thanks a lot
yeaaah merci bro
this was the perfect fix thank you!
that was really helpful thank you
Cute Block! :)
Super. Thanks.
Thanks for the video
Thank you!
thank u, ur method help me to solve some problems !!
I tried this and it fixed the problem but caused all my particle effects and some other stuff with physics and gravity just fall through the tilemap, so instead I just left the tilemap as is and changed box collider to a capsule collider for the body and an edge collider on the bottom and that seems to work as well
Thank you for the video
when ı use composite collider on tilemap collider it become empty box so chacter have change to get inside tile map composite body if forced :( is here any one know a solvation ? ı want it behave like normal collider
Merci beaucoup pour les explications et la solution :)
Nice!!! Thank you a lot !
This video was exactly what I was looking for, thank you!
Edit 1: I've been continuously having a problem where the character now falls through the tiles, if going at high enough speeds. (I'm using a capsule collider 2D, with no friction on a 2D physics material.) got any solutions?
If you haven't already found a solution since it's been 2 weeks, I think the problem is that your using discrete collision detection. On your rigidbody, in collision detection, change it to continuous, because discrete checks it every frame, so you could be on one side of the floor one frame and the other side on the next frame.
@@Treace-c8m That totally worked! Thank you, that method saves so much time rather than placing colliders by hand.
oh wow just came here to say that I skipped making the rigidbody static and it fell off the screen which was hilarious, then I siad oh, I will just set gravity to zero. My whole fence moved when I ran into it. I fixed it now.
Thank you so much
Ohhhhh, merci tu me sauves. Tu parles super bien anglais GG !
Thank you
Thank you so much!!!
My problem is that composite colliders are prone to other rigidbodies getting stuck inside them. Still looking for a way to use boxcolliders on my tiles without getting the snag issue.
I never had a rigidbody stuck inside a composite collider, I'm curious in what situation does that happens to you? Do you work with high velocity objects? Depending on your use case you might be able to get away with limiting the velocity to a max speed through code.
Something else I didn't mention in the video that you could try is to keep all tiles as box colliders and try to detect slopes ahead of your character in your character controller script using a raycast in the forward direction (or an equivalent Physics2D.OverlapCircle). If you detect an edge (which is just a very small slope) and your character is trying to move forward you can move the player on top of the slope. See an example here: gist.github.com/Garfounkel/be99b53f7ce62cf5d7653a4f9fcea331#file-charactercontroller2d_checkslope-cs
Change your composite collider settings from outline to polygon. Fixed the issue for me.
exactement ce que je cherchai merci beaucoup ;)
Merci pour le tuto !
thanks a lot! this helped
Thank you!!!