Support Forum

How to judge whether there is a straight path from my position to the target point?

Hey!I use the keyboard to control the movement of my character with recast graph. When I press the direction key, I set the target point to a distance in the front direction of the current character. But I found that in some cases, I got the wrong results. For example, there is a gap between the character’s current position and the target point. I hope the character can stop at the edge of the gap, but the character will try to bypass the gap to reach the destination. So I hope to judge whether I can reach the target point in a straight line from my position, so as to solve the problem.Can someone help me?


You can use a graph raycast.

See Documentation


GraphHitInfo hit;
bool anyHit =, endPoint, null, out hit);

I’ll try it. Thank you very much for your guidance