How do I make hitboxes for sprites so the Player doesn't phase through?

Im trynna make blocks you can’t go through

Hi, giving a bit more information would be useful to get a good solution for your problem. Collision boxes alone don’t prevent your player to go through blocks, you also need to have some events for that. Based on your post it is not clear whether you know that or not.

Generally, glitching through walls etc. can happen if you have a character with different animations and different collision masks for each frame. It is better to have one consistent collision mask for all animations. You could also make a separate collision-sprite that you attach to your player character and hide - but it depends what your game looks like and what you want to do.

1 Like

Hi CrystyMD, another answer is to use an action to prevent the player from going through the box.

For the player, use this action:

image


Which will result in this:




and thiis. The player movement stops when it hits the block…

image

1 Like

Omg thank you so much Bubble, you’re a saver, but sometimes i can phase through them or glitch through or some parts of it don’t work

1 Like

That’s good to hear. As for the problem, Drona has given some excellent advice so if it didn’t help your problem then can you give more info or post screenshots of the sprites, masks or something? Also, are your blocks very narrow? I’ve had problems with this in the past and made them bigger and then the player wasn’t able to get through.

image
i have a bush that i put to be separate from the player, if i go to the up and right parts of the bush, i phase through and stop (the player is half covered by the bush), but if i go to the down and left parts of the bush, it completely stops me and doesnt allow me to phase through the bush (this is what i want for the entire thing). basically some parts stop me as intended but some parts allow me to phase through half way, and this seems to happen with every single thing i put to be separate from the player’s hitbox

What do the hit/collision boxes look like in the editor for each object?

And do you mean passes, not phases? It’s a term I’m not familiar with otherwise.

image
passes, phases, same thing. I use a blue square as an object’s hitbox and a red square for the player’s hitbox
Also how do i make it so that the blue hitbox doesn’t cover the bush in the editor mode? i want it to be like the player

You can modify the collision box in the sprite editor:

You can then drag the vertices/corners, or add more and move them, to fit around the object image.

1 Like

You can adjust the z order in the object's properties like this:

The problem of me passing through some parts is still there

How did you implement movement in your character? I setup a quick test with separate object and a player object controlled by the top down movement behavior and it works fine. I tested different scales of solid objects and I haven’t been able to pass through them. You could try changing to the top down movement behavior and then simulating key/screen presses, if you haven’t already. Then you should have no problem with the separate objects action.