Player behavior (events) to all other player objects

I have created a typical player that moves and shoots bullets and I want the player to have skins. Is there a way that the behavior (events) of the default player can be copied to other player objects (skins) instead of doing again and again the events of the default player because it’s time consuming to create events again and again.

You can add all player objects to an object group and then reference the group in your events instead of the player. This way the events apply to all player objects and all instances. You can read about it here:
http://wiki.compilgames.net/doku.php/gdevelop5/objects#organizing_objects_into_groups

An other option is to organise your events in to event based behaviors and attach the behavior to all player objects just like any other behavior. You can read about it here:Custom behaviors: create your own behaviors with events [GDevelop wiki]

If you would like to re-use the player objects not just for the player but for enemies too, you can use object variables to flag object instances if player controlled or not and then execute player events and enable player behavior only if player controlled. You can read about object variables here:
http://wiki.compilgames.net/doku.php/gdevelop5/all-features/variables/object-variables#object_variables

3 Likes

Ddabrahims answers are spot on. The only other thing I would mention is that if the skins are visual only, you could just make them other animations on the same player object.

Then just store the selected skin in a variable, and call animations by name+skinvariable.

1 Like