Hi there, I’m making a top down rpg with puzzles along the way, and I’m stuck on how to make a specific one.
See, I would like to make a wire puzzle. As in, the player have a grid (for example a motherboard let’s say) and they can scroll down or up to choose an horizontal, angled, or vertical wire. They then need to connect two dots with these wires.
Now the wires system works perfectly, but I don’t know how to make the game detect that the starting dot is connected to the ending dot by the wires.
Hi - What have you got so far?
are the dots and wires sprite objects? or are the wires shape painter objects?
do they snap to a grid?
if the wires are sprites then have the origin and centre point at one end A and a custom point ‘end’ at the other end B. For shape painter wires (much harder) use an array of points for each wire (wires[wire.id][point].x, wires[wire.id][point].y). You could also have the wires as a chain of objects connected by physics joints and there are threads on here that would be useful for that.
Build an array that contains the info relating to connections
the dots and wires need a number variable to give them a unique ‘id’
this is either done manually on the editor or at the beginning of the scene using repeat for each object.
then to build the array of connections
repeat for each dot and inside of that repeat for each wire …point A inside dot change - Connected[dot.id].PointA.wire.id and then do the same for point B of the wire.
what i would do is, and this might be frowned upon by more seasoned coders is have the id numbers of wire and dot start at 1 so that 0 is null
i tend to scan through an array and so whether a child is not equal to zero - but i know there are better ways of doing this using array tools!