Enemy going through walls

Hello,

For some reason my enemy is going trough the wall, but just for one square. I tried adjusting the colliders, but to no avail.

image

It seems that the collider in the tilemap is not correct, I don’t know how to solve it.

Any ideas to solve this?

Thank you!

Edit: Added more detail.

Have you added a Composite Collider 2D to your tilemap collider? Here it is a documentation page about it:

You may need to play around a bit with either the offset, the vertex distance or the radius to get it exactly on the outer edge. Keep in mind the distances need to be really small (that’s why Vertex standard is 0.0005).

Hi @Jcraposo,

Your second screenshot shows the problem. The edge collider was not generated correctly. That is a known issue in Unity. Try to disable the Tilemap Collider component and enable it again to force Unity to recalculate the collider shape. The enemy’s code for flipping gets triggered when its collider hits the edge of the edge collider, not some sprite.

Did this help you fix the issue?

Thank you for your replies. So I tried resetting the tilemap collider, but it didn’t work.

What I did was “paint” over the tilemap again

image

image

And it reset the collider, very weird.

Good job. Did that fix the issue with the enemy?


See also:

Yes!

Thank you for your help!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms