Variable referring to multiple objects?

Hi! Long story short. My strategy game has multiple 'unit' objects stored under 3 parents: player1_par, player2_par, and cpu_par. The parents are all supposed to attack one another, so that player1_par's children objects attack player2_par and cpu_par, and so on. I can store both the player parents under a common grandparent object, but can't store the cpu_par under the same parent with either of the player parents; it gets messy quick with these parents. So can I assign a variable to store both parents under it, f.ex.

var enemy=player1_par, cpu_par

Or something of the sort?
So whenever an object refers to that variable, f.ex. if distance_to_object(enemy) , then it will automatically refer to all objects stored under the variable name?
 

Slyddar

Member
Might not be possible with your setup, but usually in multiplayer, there is one player object, and you run instances of it. That one object has variables that allow each instance of it to be controlled by one person only. Doing it that way, you have an enemy that has the 2 players as it's enemy and you have each player who has the enemy as one, and the other enemy is an o_player instance that does not have it's id equal to the id of the player running the code.
 
Last edited:
Might not be possible with your setup, but usually in multiplayer, there is one player object, and you run instances of it. That one object has variables that allow each instance of it to be controlled by one person only. Doing it that way, you have an enemy that has the 2 players as it's enemy and you have each player who has the enemy as one, and the other enemy is an o_player instance that does not have it's id equal to the id of the player running the code.
Thank you for the helpful answer!
all in all, using a variable to refer to multiple objects, impossibility?
 
Top