Uninomicon

Documenting the dark corners of the Unity Engine.

User Tools

Site Tools


physics

This is an old revision of the document!


Physics

Physics.CapsuleCast

Physics.CapsuleCastAll

CapsuleCast may sometimes return invalid an 'invalid hit', where hit.distance == 0 and hit.point == (0,0,0) 1). By the documentation, this should only happen when the starting cast position already overlaps a target geometry.

Occasionally, however, CapsuleCast may return an invalid hit in certain uncommon but valid cases. For example, hitting a triangle mesh exactly edge on2). Adding a small fudge value to the cast direction can alleviate this.

1)
It's not documented for all casts, but it is documented for SphereCastAll: https://docs.unity3d.com/ScriptReference/Physics.SphereCastAll.html
2)
ie. ray.direction == colliderTriangle.normal
physics.1659061245.txt.gz · Last modified: 2025/01/15 04:35 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki