How to raycast 3D check?

94 views
Skip to first unread message

Aresky Aresky

unread,
Aug 31, 2022, 10:58:19 AM8/31/22
to recastnavigation
/// The raycast ignores the y-value of the end position. (2D check.) This
/// places significant limits on how it can be used. For example:
///
/// Consider a scene where there is a main floor with a second floor balcony
/// that hangs over the main floor. So the first floor mesh extends below the
/// balcony mesh. The start position is somewhere on the first floor. The end
/// position is on the balcony.
///
/// The raycast will search toward the end position along the first floor mesh.
/// If it reaches the end position's xz-coordinates it will indicate FLT_MAX
/// (no wall hit), meaning it reached the end position. This is one example of why
/// this method is meant for short distance checks.

How to get position near secound floor end position, but get wall hit ?

richard.g...@gmail.com

unread,
Dec 6, 2022, 11:19:25 AM12/6/22
to recastnavigation
The way I've done it is to get the poly ref for the end point of the trace, and then add an extra check after the raycast if it's successful to confirm that the poly ref it ended on is the same as the poly ref I was aiming for. If not, then it must have ended on a poly above or below the target and therefore failed. I did some testing and it seems to work for things like balconies.
Reply all
Reply to author
Forward
0 new messages