Hello, I'm having a weird issue that maybe you might be able to help with. My game is a top-down space shooter, and I'd like one of the player's abilities to be a sort of "blink" teleport, where you jump a bit ahead in whatever direction you're moving. That part I was able to get down just fine and in open space it works perfectly just like this:
But the problem I'm having now is, I don't know how to confine the player's teleporting to the playable area. Here's a rudimentary doodle as an example (the black part is the wall of the playable area).
Right now what happens when the player blinks is this:
The ship goes inside the wall and just gets stuck there. What I'd like to happen is something like this:
The player stays outside the wall and only teleports as far as they can go before going inside it. How would I go about coding something like this?