Passing multiplayer gamepad variables to another object.

I currently am working on a multi-player game, which has numerous special weapons.

Player one and two both function fine and can enable special weapons independently.
However, disabling a special weapon is not working correctly.

For example, when shield is activated, it will remain active while R1 is held. The issue is that my shield object is not "seeing" the controller variable for the R1 button of the player that enabled it and is disabling immediately.

In the Step Event of the player object I am running two scripts. The first one has all the double tap and special button presses as variables. The second is to activate my specials when certain variable combinations are pressed and implemented as a switch statement.

I'm thinking I have to move the main controller script into an object (possibly the special script as well). Afterwards, I can set it as a parent for the player and the special objects it instantiates.

Any guidance/suggestions/corrections would be much appreciated. Thanks!


No need for parenting, you can always read another object through objectname.variabename notation. You can read the player object if that's where you are storing the button states, though it would be a good idea to make it an object of its own as it makes it portable between projects. You can store the spawning player's ID to the shield object so you can refer to the correct player instance when checking state of controls.
Yes, that is what I had done. I passed the id of the player to the shield, so it can follow its x and y coordinates. However, the shield object did not recognize my "player_r1" button variable, which is either 0 or 1 (pressed or not pressed).

To resolve my issue, I just added my player id variable as follows: player_id.player_r1. Now the shield correctly displays until it r1 is released.

Thank you NightFrost! Your clear explanation helped things "click". I didn't even think about using the player_id that way until I read your explanation (twice). :)