I'm trying to figure out the best way to associate two instances of two different objects in the editor. Basically it's a lock-and-door situation, I have a gate and a bucket (put a certain number of things in the bucket to open the gate). I want to be able to easily get the associated bucket if I pick a gate and vice versa.
Containers won't work for me for a number of reasons:
- All gates have buckets but not necessarily all buckets have gates
- I want to be able to associate the two objects from the editor since placements will vary and there are multiple bucket/gate instance pairs
- both object types already have containers for other purposes and so can't be added to each other's containers anyway
I have a number of ideas for solutions but would like opinions on what might be the best course (or ideas for solutions that I'm missing). Please let me know what you think!
1. UIDs as instance variables (so the bucket object has a gateID and the gate object has a bucketID and I enter UIDs manually). The problem here is just the overhead of having to enter and potentially update UIDs, and the errors that might result if I clone a pair and forget to update their instance variables
2. Use "Pick Nearest" to get the closest bucket to a gate. Works in theory as long as I always keep buckets next to their gates, but breaks down if there ever comes a case where this isn't true (or if two bucket/gate pairs happen to be near each other and might mess this up).
3. Create a "linker" sprite that I drag over both bucket and gate, and use overlapping checks to see which objects are overlapping the same linker. Might be unwise to add unnecessary collision checks.
4. A combination of 3 and 1, where I do one collision check at the beginning of the layout to set up the instance variables and then use UID picking elsewhere in the event sheets.
If you have any thoughts on these or better ideas for ways to solve this, please let me know. Thanks!