When the ray is not obstructed it returns the RayEndLocation, as it should. But when the ray is obstructed it returns the RayStartLocation, nothing in between. In the source I can see there are a lot of reasons for a raycast to return the RayStartLocation while still being a hit, or the hit time being 0, still meaning HitLocation would end up at the start of the ray.
Did I overlook anything, is this working as intended?
I’m not seeing this. However, NavigationRaycast is weird, and doesn’t do what you might think it does.
I expected (and was hoping) that NavigationRaycast was meant to perform a Raycast against the navmesh, so it could be used for picking navigable spots for, say, issuing movement orders to units in an RTS.
Instead, what it appears to do, is it performs a raycast which is unobstructed only when the ray is within the bounds of the navmesh, projected up and down. So if you are standing in a pathable area, the ray will shoot out until it hits the “edge” of the pathable area, and then return a hit location along the ray above the edge of the navmesh.
Is it possible that the start location of your raycast isn’t above pathable space? Then I’d expect it to return the RayStartLocation immediately, since it would always be obstructed due to starting outside the pathable space of the level.
I just got stuck on this as well. It’s pretty crazy. If you start the raycast at non navigable location, it returns the original blocked location and returns true (success), so essentially there’s no way to tell if the location is valid on invalid. The bool will return valid even for invalid locations -.-