I'm making a fighting game. In the code, I have characters who are hit affecting the global variable "Player1Percentage" or "Player2Percentage" depending on which player value they have for their instance variable.
Currently, I have 2 separate events for whether a character with "Player = 1" is hit by a hitbox with "Player = 2" and vice versa, then adding the hitbox's damage value to "Player1Percentage" or "Player2Percentage"
I want to consolidate my code for when I add future characters. My plan right now is to add to a value "Player(character.Player)Percentage" through javascript so I don't need to have multiple events for each character. However, javascript does not seem to like inserting a value into another value.
How do I affect a variable like this correctly?