[2D] How do most people make levels with proper collision AND textures?

So, when I put down a series of 1x1 “floor” prefabs with a Box Collider 2d, walking across them is a nightmare. My character will get caught and be unable to move constantly. This could probably be alleviated if I used a sphere collider for my character instead of a box collider, but that would make walking off edges not work like they do in traditional 2d platformers.

Or, I can stretch out a floor prefab and just have one big box collider for a walkable segment using the scale value on the transform. This works great! But then the texture is stretched and looks awful. I don’t think I’m supposed to make a new prefab with a custom material for every possible length and height of floors, so how do I make the texture/sprite tile when I scale it? Is there a way to create a new material specific to each gameobject without doing so manually?

I only need one of these two things to work, but since neither do, I’m kind of in a bind. How do most people make levels for a 2d platformer?

you can modify the collider size without changing the object's size. just use "Edit Collider" button in inspector

Could you at least put a picture of the problem?

1 Answer

1

I’d recommend never using the scale transform to create variations of a prefab - you’ll inevitably stretch the texture.
Instead, you should create separate prefabs for, say 1x1, 2x1, 4x1 blocks that have the correct UV coordinates assigned to their vertices, so you can assign the same material to each and it will tile nicely while also only requiring a single collider per platform.

Walking from one box collider to another causes massive problems the majority of the time, so anything less than the whole floor being one collider is unacceptable for now. I'm going to use the solution I found and wrote about in my comment, but thanks for the suggestion!

"when the player gets hit" if that were true you would see the debug log, so the player couldnt be getting hit. Check your physics matrix. Make sure you have a rigidbody on the object