Physics and Layers

Subject: Issues with Layers, Collisions, and Code in 2D Fighting Game (Godot 4.5)

Hello everyone,

I’m very new to both programming and using Godot Engine, and I’m running into some problems with my project.

The Project:
I’m developing a 2D fighting game. My idea is for each character to automatically get their physics layers and collision masks when they are instantiated into the scene. I want this because I plan to have 10 or more characters and need an efficient way to manage them.

The Problem:
The system isn’t working well. Collisions aren’t behaving correctly, and I’m having trouble properly assigning or configuring the layers between the different character instances. I’ve tried getting help from AI, but even that hasn’t provided a working solution.

My Question:
Could anyone guide me on the best way to handle layers and collisions for multiple character instances in a fighting game? Is there a recommended way to set this up via code or from within the scene?

Any help, code examples, or advice would be greatly appreciated. Thanks in advance!

You should use one Layer for all the characters not a layer per-character, maybe a layer per-team like enemies versus players in a co-op beat-em-up.

If you are doing a 1v1 fighting game it’s fine to operate on layer 1/mask 1 exclusively, using if statements to prevent self harm

2 Likes

Bro, can I message you to see it?

I’m doing something like that, but it’s not working as well.

You should share your code on how you instantiate the nodes and how you setup the layers / collision objects here if you want more help.

2 Likes

Sorry, I was looking for how to upload to GitHub for an easier way to share it!

This is my code so far: I have 2 ‘complete’ characters and 1 ‘on the way’, but the colliders don’t work as I want.

If I missed anything, please let me know, and I can share it!