我已经到了一半,现在让 XBoundary 调整其位置,以便始终以 90 度锁定到 ZBoundary
ZBoundaryRef.transform.Translate((-1 * distancePerZMovement), 0, 0, Space.World);
// using Space.World so transforms are using the global coordinate system!
// what I've done here is say, move the XBoundary Z-CoOrd so that it aligns with the ZBoundary Z-CoOrd.
// the origin of an object is at it's centre point so we need to take this in to account to ensure they join at the corners, not in a Tshape!
float difference = (ZBoundaryRef.transform.position.x - XBoundaryRef.transform.position.x);
float adjustment = difference + (ZBoundaryRef.transform.localScale.x/2);
XBoundaryRef.transform.Translate(adjustment,0,0,Space.World);