GMS 2 Avoid duplicated events (SOLVED)

Not open for further replies.


I like to know the best way to avoid duplication. Here is a simple example:
* game for 4 player
* each player has 1 headquarter

Here are some options but I hope there are better options I do not know until now: object for each player
(+) organization of a room is easy
(-) events have to be duplicated for each player object
Q: Does GM provide a option so objectA can inherit events from objectB? object for all player
(-) organization of a room is complicated
(+) no duplicated events
Q: I do not know how to define which object belongs to which player in a room. What I could imagine is a start script which will assign each player to one object of a room.

Greetings michael


You can set parents per object. But I assume that your objects are generic and can be used (i.e. a barracks objects that can be owned by any player and not a new barracks object per player) then you can use the object id used in the room editor as a unique id to be used to a specific controller object, or even just set a variable in the objects creation code (right click on the object on the room editor) to an arbitrary variable which tells which object controls it.
I mean this with no disrespect, but the questions you are asking are really base level GML object and variable stuff. Have you run through any tutorials from people like Shaun Spaulding (or others)? They won't necessarily address your specific game type, but the base coding ideas apply to all projects. I'd highly recommend doing some of these tutorials (as many as you can) so you can get a better understanding of how objects can be utilized. It should then become fairly apparent how to implement your specific system.
Not open for further replies.