Here is one approach you could try to determine the ledge height:
- Shoot a horizontal ray towards the direction of the wall (hit point:
hPos
)
to detect the x-position of the wall- Shoot a vertical ray downwards from the
hPos
+epsilon
to detect the
y-position of the ledge
epsilon
: a small value that is used to avoid an edge-case where the ray narrowly avoids the target due to a floating-point error.
After this info is obtained, it’s just a matter of performing an animation at a specific position relative to the obtained point.