Multiple collision boxes for a 2.5D shooter

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Heff-Money

I’m trying to make a 2.5 D shooter, and have limited development experience, Godot or otherwise. I started with a tutorial for a top-down shooter and have been modifying it for my needs. So far I’ve a reasonably fun prototype with both a player and enemies that can shoot at each other.

I recently started improving the tileset - square pattern, not isometric - but I’ve run into an issue. My character sprites have somewhat realistic proportions but the collision boxes only cover the torso. That’s a hard gameplay decision as I really want to encourage precise aiming.

Interactions with the map works well enough if everything is taller than the characters. But I want to have things like tables, benches, crates, etc. that are shorter than the characters, and it doesn’t work. From the top end the character’s legs go clearly over/under the obstacle, and from the bottom end the character collides way too far away from it.

My preferred solution would be to have a separate collision box that’s goes around the characters’ feet for determining how the character interacts with the map, but does not collide with other characters or bullets.

Alternate solution is to move the collision box to the feet and displace all of the sprites - so it looks like the bullet is hitting the torso when in fact the bullet’s box is lower than the bullet’s sprite and hitting the feet.

Third solution is to forgo all the obstacles and just stick with tall walls.

So how painful would it be to implement the preferred solution? How jenky is the alternate solution?

:bust_in_silhouette: Reply From: exuin

I would have separate collision boxes for hit detection and collision. I think your preferred solution is the best one. It wouldn’t be that painful to implement the preferred solution. At least less painful than displacing all the sprites. You just need to set up all of the collision layers properly.

Well, it seems to be a bit harder than that. I did some searching, found somebody who had a similar problem an was able to add an Area2D with a CollisionShape2D and then fixed it with the physics layers. But, they were trying to make it so the top half of the player could hit an item for pickup.

I’m trying to make the top half of the player get hit by another object. So even when I set the layers up properly the bullet would only react with the KinematicBody2D layers and ignore the children’s layer setup.

But I just changed the Area2D to a StaticBody2D and now the bullets are at least stopping. It looks like I have to refactor my hit handling, so fingers crossed, but likely the problem is solved.

Heff-Money | 2021-06-18 17:07