In good news, I now have a script that lets objects be "aware" of how many of a given type of object are around them.
Still working on getting the distances between them returned as well. Ideally the script would enable the object to request how many of X object are within distance Y, and get an array returned containing either distances or the object references.
Why do I need this? Good question. It does seem like a silly script taken out of context.
Our main character needs to know how if he is fighting one enemy or a group. Combat changes a bit depending on which situation he is in, so like a real fighter, he's got to be dynamically aware how close the nearest enemies are and change his moves accordingly.
In turn, the proposed system lets the controls be super easy (just one attack button) while the combat itself can vary from "doing combo attacks on the big thug enemy" to "swinging all around to defend from all sides". It should be pretty fun once it all works.
But mainly, having him aware of how many enemies are near helps solve the problem a lot of games with a combo attack system have.
Yes, game design rambling oncoming:
Anyone who's played them knows one of the most annoying things ever is to have your main character "lock on" to one enemy, only to be smashed to bits by the three other surrounding enemies.
Realistic, sure, after all, you were the one that mashed the attack button telling the main character to start the combo attack. However, that doesn't make it any more fun to be a victim of this when you panic in the heat of battle.
Most games call it "skill" and leave such a trap in on purpose to punish the player for making mistakes. For a combat focused game, that would be an acceptable additional complexity. There's nothing wrong with it actually, assuming your game is mainly about fighting or has a complex fighting system in it.
For games that don't have such a system, they usually solve the "combo gets you killed" in a few ways:
-Having the other enemies mostly just stand there while the combo is going on. This works, but makes the enemies look kind of stupid since they go from charging into battle to just standing around screaming while their friend is brutally murdered in front of them. Assassin's Creed players know this all too well, it happens so much in that game it's often immersion breaking(They've been trying to fix this in the sequels, with varying success).
-Splitting the attack commands into a "Light attack" and "Heavy attack" option. This creates two buttons in the controls, which works for complex action games, but for this game I want to keep controls simple so anyone can play. In a game where fighting is only going to be a third of what the player is doing, it doesn't make too much sense to make it so complicated.
-Give the player a control for "dodge" that interrupts the combo, even when it's been pressed into motion. This is fun, I like games that do this, but once again, we're adding a third button that only exists for the sake of combat. Combat in turn is only a part of the platforming game experience, and so unless we can come up with a lot of platforming uses for the button, it's just adding more complexity to the controls.
My game actually sort of uses the third solution without adding a third button, the Jump button will cancel a combo by jumping out of it. This actually serves a purpose in platforming, you can jump higher by kicking off enemies or combo attack-able elements in this way. Of course, this alone isn't enough to fix the initial problem of getting attacked by many enemies at once.
And so my final solution is to avoid ever creating the "combo mobbed" situation in the first place, by making the main character himself only be able to combo attack if there isn't other enemies nearby that might interrupt him. It sounds simple on paper, but in reality there are a lot of little scripts that need to talk to each other to make it work and feel right. In the end, it should just feel like the main character is "behaving smart" and helping the player out. Since the game is primarily focused on collecting and platforming, having the combat be a bit light should work just fine.
Not sure how soon I can get the system up and running with all this illness going around. But I think it looks really good on paper, and I really want to try it out in practice.