Hello,
Can someone help me understand what's going on in CapsuleCastCustom :
public static bool CapsuleCastCustom<T, C>(in T target, float3 point1, float3 point2, float radius, float3 direction, float maxDistance, ref C collector, CollisionFilter filter, QueryInteraction queryInteraction = QueryInteraction.Default)
where T : unmanaged, ICollidable
where C : struct, ICollector<ColliderCastHit>
{
CapsuleCollider collider = default;
float3 center = (point1 + point2) / 2;
CapsuleGeometry geometry = new CapsuleGeometry
{
Radius = radius,
Vertex0 = point1 - center,
Vertex1 = point2 - center
};
I don't understand how the CapsuleGeometry is built.
Based on the definition of the fields Vertex0 is "The start position of the capsule's inner line segment." and Vertex1 is "The end position of the capsule's inner line segment.".
A capsule being 2 sphere separated by a cylinder, I understand the "inner line segment" as the height of the cylinder.
So in other words Vertex0 and Vertex1 should be the centers of each spheres.
Given that understanding I don't understand why in the world I would substract the center position in :
CapsuleGeometry geometry = new CapsuleGeometry
{
Radius = radius,
Vertex0 = point1 - center,
Vertex1 = point2 - center
};