I was hoping to link several instances of a “hitbox” object to a character, and also link several more instances of the hitbox to enemies, and link them all such that when the player or enemy moves, I just need to take into account linked objects and the instances are taken care of. Is this possible, or will I need to create an object for the player hitboxes and an object for the enemy hitboxes, then link them separately? I feel like I will have an easier time with linking instances directly.
You can link specific instances, otherwise the link automatism would be useless
When you use the action “Link all Hitbox with Enemy”, GD will link every “active” Hitbox with the “active” Enemy. With active I mean the objects taken into account by the event and parent events conditions.
For example if you add a variable “player” = 1 to some Hitbox, and then do:
Conditions: Variable "player" of Hitbox is = 1
Actions: Link all Hitbox with Player
It will link only the Hitbox objects with the variable “player” = 1 to every Player object
I see now, so each instance can have a variable stating what other instances it may belong to. I really appreciate the info!
Yes, but doing it with variables is just an example, you can use any condition to taking into accout the instances you want, for example:
For each object Enemy:
Conditions: The distance between Hitbox and Enemy is < 100
Actions: Link Hitbox and Enemy
This code will link every Enemy object with the nearby Hitbox objects (at a distance below 100 pixels to the Enemy)