How do I bind instances of one type to others?


#1

Hi!
How do I bind instances of one type to others? For example: there are 4 instances of enemies of the same type, 4 health bars of the same type. How do I link each health bar to my enemy ?So that each enemy has its own lane
image


#2

Use Link to
When you create the health_bar use Link to Enemy, that way when you move the enemy and health_bar add Take into account Linked objects


#3

health_bar is already placed on the stage, I’m not creating it


#4

So you place 4 enemies and 4 health_bar in the level?
Is a good practice to use events to create enemies dynamically.

For instance:

Repeat 4 times
Action:
Create enemy at x, y
Create health_bar at enemy.X(), enemie.Y()
Link health_bar to enemy

Then to reference all together
Foreach enemy
Action:
Change health_bar position to enemy.X(), enemy.Y()-10
Take into account linked

Of course this is pseudo you need to look at GD for the names of the actions.


#5

??? Not if you want them at predetermined positions in the scene.


Remove the Health bars from the scene, and add them in the events, pretty much as @UlisesFreitas suggested, but without the create enemy at x,y. Use a Repeat for all [object type] event.