Reposition the player relative to which part of the collider it hit for endless hall? (790145)

I’m trying to make an endless hall by having two colliders, one the trigger that repositions you and one for the target. The target can also be the trigger and vice versa, since it works like a portal system. I check if a bool is false when I enter the trigger, then I just set a bool true on the target and set it to false when I exit the target collider (to stop loop repositioning). The problem I’m having is making the player reposition to the target collider but offset to the part they hit on the trigger collider. If the colliders are the same size, is there a way of checking which part of the collider they’re touching and when moving to the new collider, retain that offset so the repositioning matches perfectly?

Since they’re Trigger Colliders you won’t get any help from the OnTriggerEnter() method itself. But since you said they are the same size, could you just get an offset from the center and move to that same offset relative to the other collider?

For example:

void OnCollisionEnter(Collider col) {
  var offset = col.transform.position - transform.position;

  transform.position = theOtherCollider.transform.position + offset;
}

Thanks, I did try that method but it didn’t seem to align properly for some reason, I’m not sure if it’s because the orientation is different when they’re rotated. I’m only using trigger because charactercontroller will stop moving if it’s not a trigger, unless I’m mistaken?

Using a trigger collider makes sense.

So when you tried the offset method was the position correct but the rotation was wrong? How about also adjusting the rotation relative to the new collider? I haven’t tested this code but it should work…

void OnCollisionEnter(Collider col) {
  var offset = col.transform.position - transform.position;
  var rotOffset = Quaternion.FromToRotation(col.transform.forward, transform.forward);
  transform.position = theOtherCollider.transform.position + offset;
  transform.rotation = theOtherCollider.transform.rotation * rotOffset;
}

I actually hard-coded the offset rotation for the player per collider for testing (since they’re only rotated 90 degrees for now) but thanks for that, I’ll make sure it’s based on the colliders rotation. The problem is the player just warps to the centre of the collider or doesn’t seem to warp at all:
euphoriccreepyguanaco

Found this, it works perfectly: Portals: Transformation of ported Objects - Questions & Answers - Unity Discussions