Home > front end >  My sprite cover the edges of other sprite Unity 2D
My sprite cover the edges of other sprite Unity 2D

Time:02-07

I'm working on a procedural world generation in Unity 2D. But when It spawns my blocks, blocks cover each other. What could be the possible problem? How can I fix it?

Thanks for your help.

Screenshot: screenshot

CodePudding user response:

It might be because you made the boxcollider2D on your blocks a little too small. Try to fit the collider perfectly with the edges of the block

CodePudding user response:

Okay, finally managed to solve it. For future people, here's the solution:

So when you export your sprite from Photoshop or whatever program you use, you export it with a preferred size (ex. 128×128 px).

What you need to do is, go ahead and click your .png file in Unity. In the inspector window, you will see an option called "Pixels Per Unit". You have to enter the correct sprite size there.

Apply the changes, and there you go!

  •  Tags:  
  • Related