heyo!
i’m recently trying my hand with unity by making a game about space stations and i have a question:
as the title says the objective is to give the player the ability to build the stations piece by piece, in a modular way, but i’m not sure how should i approach the “docking” procedure.
i would like each station module to be able to be attached to eachother by childing itself to the module it’s being docked to and my first idea was to add a trigger collider to each docking port so that when they get under a specific distance this would happen.
my problem with this tho is that if i make an universal “docking port” prefab when two get into contact they would both try to child themselves to one another and im guessing that would be trouble, making two separate prefabs (like a “master” and “slave” port) woudnt work either because i cant say beforehand wich orientation/side a player will be trying to to dock them.
do you guys have any suggestion on how shoud i try to do this? thanks in advance for the help!
I would give each dockable piece a sequential id when it is created. When they dock, always pick the lower number to be the parent and the higher number to be the child.