Godot Version
4.3
Question
so i have two nodes, lets call them segments. each segment has two more nodes, lets call them sockets.
i have a function that ‘attaches’ one node to another using sockets. the function specifies which socket on either segment to attach together.
basically, what i need to do when i attach segment b to segment a, using a’s socket t and b’s socket w, is to set segment b’s transform (the position and rotation) such that socket w ends up with the same global transform as socket t
i’m starting by parenting segment b to segment a but this isn’t a necessity of the structure. then i am setting b’s global rotation to a’s global rotation plus the difference between the socket rotations. then i’m doing the same for global position
this seems to kind of work to align the segments by the sockets. now, what i really need to do is actually align them so that the sockets are touching end to end, that is socket w actually needs to be facing the opposite direction as socket t so that the segments are attached end to end instead of overlapping. i’m not positive how i’m meant to ‘invert’ a rotation along the x axis, so i’m just doing this
now for some reason just inverting the x basis does not really work, though it seemed like it should. inverting all bases is wrong too. i’m currently trying to just invert x and z which for some reason is the most consistent, but it still has some cases with wrong alignment.
is this the best way for me to go about doing this socket attachment thing? what am i doing wrong with the inversion step here?