I'm working on implementing portals, and I have this function for teleporting the player:
global_transform.origin = portal.portaltarget.to_global(Vector3(-1,-1,1)*portal.to_local(global_transform.origin))
When the portals face towards each-other, it works as expected (although when you look behind you there's some clipping that I still need to fix).
But when the portals are facing away from each-other, the player gets teleported to the wrong place.
I feel like i'm missing something obvious. Could someone help?