Check If Pawn Teleport Location Valid Using Navmesh

We currently have a player pawn that can teleport around a play space. However, we would like to prevent the player from being able to teleport inside of objects, such as a table. Right now we check that the teleport location is relatively flat before allowing it to go off, but we need that additional check to see if the new location would put the player inside of an object. Ideally the player would teleport as far as possible in the specified direction but stop at the object.

I thought a navmesh might be a good way to determine if a point is valid (see navmesh wrapped around table in image), but I don’t know how to query the navmesh to ask if the point is valid. I’m not trying to do AI as this is a pawn controlled by the player.

We are moving the pawn using SetActorLocation(). Is this doable using Blueprint? Is there a more elegant or simpler solution?

Thanks.

104054-table_navmesh.png

You can use ProjectPointToNavigation in BP, but it “just” gives you location snapped to navmesh (within given bounds). If projection fails it gives you the very same point you passed in. We’re going to address that in the future.

In C++ everything’s possible! :wink:

Cheers,

–mieszko

If your world is set to known collision types, you could just check for collision with that type at the destination location.