Our game has a mechanic where the player presses a button to "shift" to another location on the map. Right now, we use SetLocation to do this, and it works great.
There are certain times where the player cannot shift to the other location on the map - for example, if there is some geometry in the way. In these cases, SetLocation returns false, and we go on our way. So far so good.
However, we have a small problem implementing a related feature. As the player is walking around the world, we want to add a HUD indicator that tells the player if the location they are currently at would work for teleporting - is it obstructed or not?
Our first instinct here is to just check in tick if every frame if SetLocation returns false. But the problem is that when SetLocation doesn't return false, it actually moves the player - not what we want to have happening every time tick is called!
So, my first question is: is there an alternative function that will just return true when a position is unobstructed instead of moving the player there? Or what does SetLocation do internally that we can mimic in our code?
Here are the solutions we are currently looking at:
1) Perform a very small trace at the teleport location each frame to see if it hits anything - if not its clear, if so it is obstructed.
2) Use SetLocation on a dummy object each frame to check the position.
3) Calling SetLocation in Tick and, if it doesn't return false, recalling SetLocation right away to put the player back in position. But this seems very hackish and not optimized.
So, one of these solutions could possible work, but as we test them out, does anyone know the internals of SetLocation and how it determines if a location is safe to teleport to?