My description is kind of vague, but I will try to explain.
I have a local-multiplayer game where all characters are controlled via different controls. These controls are stored in their instance variables.
I have movement and such all worked out, and they function by checking whether a button is currently pressed down. However, the "on button pressed" event which I want to use for attacks functions differently (as expected).
The issue is that I have multiple characters ("Body" in this case) that all have their own attackKey. When I create an event that listens for an "Body.attackKey" to be pressed, it chooses a random Body and listens only for that specific keypress and only attacks with that specific Body.
In my movement script I solve this by encapsulating everything in a "For each Body" loop, so that all the references to "Body" reference the same instance. This does not work in this issue because it is a triggered event so it does not work in a loop.
So to be clear, I want to be using "on key pressed" because I don't want the player to be able to hold the key down to attack automatically.
I am not really sure how to solve this issue in a non-convoluted way, so I would appreciate any help.