Godot V4.2.1 - Stable win64
I’ve been working in Godot to make my first original game project, a 2D beat-em-up about parrying. However I find myself a bit lost at how to recreate the faux-3D effect that beat-em-ups are known for when it comes to navigation and combat. If the hero is standing far enough below an enemy, then they should not be hit by (or be able to hit) that enemy.
The issue arises directly from my lack of experience with the engine. The hero has a hitbox which goes up to their height, but they also have a ‘Z-Zone’, a short and wide Area2D node which extends for a distance to the left and the right of their hitbox, originating from the bottom of their sprite where their feet touch the ground. My plan was to track other instances through overlapping Z-Zones, adding and removing them from an array called ‘viable_targets.’
If the attack collision hits an enemy hitbox and they are in the viable_targets array, then it calls the ‘hit()’ function that the enemy has (tracing the command back to them via the attack’s collision signal). The issue with this that I discovered while testing to see if the viable targets array was working properly is that attempting to track the enemy through overlapping areas means that viable_targets only tracks the area names, not the instance names. I can’t call the hit function from the Area2D and it feels incredibly sloppy to add another script for the Z-Zone to call just to transfer the hit() command to their parent body. There has to be a more efficient way to do this.
I have three questions, in the end.
How do I trace a child node back to it’s parent within the context of an ‘area entered’ signal?
Is this Z-Zone structure worth pursuing at all for the beat-em-up game I want to make?
If not, what would be a more effective way to handle 2.5D movement and combat?