Infinite loop in two way teleporter

I am trying to make two way teleporters but I’m getting a infinite loop when I attempt to enter either teleporter. The teleporter function is created in that way as I’m trying to make it easy to link multiple copies of the two teleporters simply by changing the tags, instead of having to hard code them.

My game mode only contains the IsTeleporting bool and is set to false by default. There is no other code.

Not really sure what’s causing the infinite loop…I suspect it’s the teleporter function for each loop

I can see a few issues with your code, the most noticeable seems to be that youre being forever teleported between the two points which could be the cause of your infinite loop.

What needs to happen is when you enter from being teleported from A or B you are set in a state which disallows any teleport until you purposefully re-initiate a telelport for eg exit and enter overlap again.

Your foor loop should have a break out too when you find the first teleporter that matches your intended destination, then you can teleport to that one location, as of now it looks like you could possibly teleport multiple times which is made worse if you are being forever teleported.

To help you could have a list in each teleporter for which actors are currently going and which are coming, so going A->B B would store someone coming, A would be someone going and when the teleport is all done and dusted you can remove them from the list. This means you can check to see if a player was recently teleported for your overlaps and it should resolve most of your issues.

Thanks for the advice! I’ve managed to fix it.