Asteroid-esque teleporting


Sorry for the hazy look, the build isn’t optimized.

Anyway, the character is currently in the middle.
I want it to be able to go out on the left and back in on the right.
I’ve been able to make that work, however with a cooldown timer.
The biggest issue currently is getting that to work in diagonals.
Due to using collision boxes I’m afraid when it goes into the corner it will only teleport the overlap it sees first.
And due to it working on a timer it then won’t teleport the other way.

So for example you go top left. It reads that you are overlapping the top collision box so it tp’s the player to the bottom left. But then because of the cooldown timer (which is only there to apprehend infinite teleporting, not a design choice) it won’t teleport the player from the left side of the screen to the right, which means the character will continue to move outside of the camera viewpoint.

I’m currently in the middle of trying to solve the problem myself by creating two arrays of the top-bottom boxes and the left-right boxes, and then allowing either to teleport from one to the other box. And then once they leave the other teleporting box it will reset and allow teleporting again. However that already has a flaw in that the player could fly as slowly as possible and then stay in the box it was teleported to, and move out of bounds that way.

Because of all these problems I feel like there ought to be a better way to do this.
Please tell me if you have an idea that could work or if there are any questions you have :slight_smile: