Player's Collision For Horizontal Shmup Games

Godot Version

4.6.stable

Question

I’m currently working on a horizontal shmup game like Einhander & R-Type. Right now, I’m confused about the player’s collision.

If I want the player to easily dodge the enemy projectiles, I have to make the player’s collision smaller than the enemy’s.

However, I also want the player to stop/slow down when close to walls, so I have to make it bigger.

How do you solve this problem?

You can just add an area2D with a different collision layer (the projectile layer you show) as a child of the character body. Add a smaller collision shape as a child of the area, and set the area to detect when a body enters.

Always make collision separate from the hitbox.
Collision make them small as you can a tiny 16x16 should do depending on your sprite.
The hit box can be slightly bigger depending on how many you want and if it can take different
damages.

Also for walls and speed. Maybe adding acceleration and deceleration to your velocity, you could
do a raycast or area2d to detect if you enter a wall and reduce speed ??

I would love to see what you make as this is a genre myself would love to explore as a pixel artist
R type :slight_smile:
Good luck

Creating a similar game myself at the moment, in the end I just rolled my own collision detection for the walls.

You could have an Area2d for collision against normal objects (enemies, bullets etc), and then use a rigidbody type for wall collision with move and slide. However I found this to be very problematic in the end.

So I just rolled my own code which just checks against the normal of a tilemap (using a raycast thats pointing the moving direction) , checks the current direction the player is trying to move in and then acts accordingly. It looks a bit janky but thats fine as I want that old school look anyway.

After through thinking (and bashing my head to the wall), this is my answer.

The player’s collision will be small and they can pass through the walls. However, it has an Area2D called crash_area that collide with walls and enemies. If collided, both players and enemies will take damage.

In most shmup game, when a plane collide with walls, they explode. So I apply the same logic here.