I need to figure out how to do a capsule cast, and get the position of the Capsule when it hits a collider, instead of the point of contact with a collider. I’m having trouble making it work in any direction, and whether it hits the side of the collider or the sphere parts.
Just used this feature recently… it’s in RaycastHit.distance
… pretty clever:
For rays it gives you the full distance, but for volumes, the docs say:
In the case of a swept volume or sphere cast, the distance represents the magnitude of the vector from the origin point to the translated point at which the volume contacts the other collider.
1 Like
Thanks, it really was that simple lol. Hovering over Raycasthit.distance in the IDE tells you that it represents the distance to the impact point, it doesnt say that its different for capsule and sphere casts. I guess I should have looked closer at the docs. I googled this problem for so long to no avail. Now to get the point I just have to add the direction multiplied by the distance to the origin point.