Hello! I’m making a game for a school project, and I had found a tutorial online for collision, but I feel as the collision is too… wide.
Attached an example of what I mean! The Orange Outline is the sprite itself, whilst the Green outline is the collision! Is there anyway for me to make the Green Outline the same as the Orange Outline, or shrink it down?
If these are tiles in a tilemap, then you may want to check the sprite editor to see what physics shape has been set for each tile.
For example, if I just let Unity figure out the physics shape itself, it will often create a shape that is too big. Take a look at the slope sprite in the picture below.
So, I’ve did what you suggested, and edited my sprites in the sprite editor. For example, I’ve edited one of my lamp posts, in the custom physics shape.
However, whenever I go into play mode, and test out the physics, it’s… confusing.
I can seemingly phase through the bottom part of my lamp post, but there’s just this chunk on top that just… stops me from walking through it. I’ve honestly go to idea what’s wrong with this.
Assuming the lamp is three tiles, you’d only put a physics shape area around the very base of the lamp where it meets the floor (projected against the floor). You have to imagine that the “box” you’re putting on is projected against the floor.
For clarification, in this second image you posted, is this the closest that you can get to the top of the lamp? Is this where the collision stops your character?
that’s correct! however, after taking a look over all of your suggestions (to where i am very thankful), ive figured out most of it! although, how do i make my character go behind the lamp? is it via a different ordering of layers?
Ive currently got
1- background
2- foreground
3- player for my layers
okay, on second thought now, ive done all the suggestions in this thread, yet it still persists.
1 - I’ve made the lamp into it’s own game object, instead of being a background tilemap.
2 - I’m only using Polygon Collider 2D for this, as seen by the green outline,
I can walk through the top of the lamp just fine, but whenever I get to the bottom, there is just huge boarder that harbors the bottom of the lamp.
thats the closest i can get to the tile. I’m starting to think its probably my character’s sprite hitbox, or something in my coding thats blocking this.
Okay, small issue. I can get it to work, but if I save + quit, when I come back, my character goes over the lamp now, and I have to fiddle with iti a bit for him to go back. It happens every time I save, got any ideas?