Beispiel #1
0
    private void CollisionSphereCapsule()
    {
        float3 spherePos    = posA;
        float  sphereRadius = extentsA.x;

        float3 capsulePos    = posB;
        float3 capsuleRot    = rotB;
        float  capsuleLength = extentsB.y * 2;
        float  capsuleRadius = extentsB.x;

        if (ColPhysics.SphereIntersectsCapsule(spherePos, sphereRadius, capsulePos, capsuleRot, capsuleLength, capsuleRadius, out float distance))
        {
            isColliding = true;

            if (resolveCollisions)
            {
                ColPhysics.ResolveSphereCollision(ref spherePos, ref capsulePos, sphereRadius, capsuleRadius, distance);

                posA = spherePos;
                posB = capsulePos;
            }
        }
    }