Issues with Capsule Cast while building a Kinematic Character Controller for Unity - Stack Overflow

I am facing an issue where capsule cast is not detecting a mesh collider. This happens in very narrow s

I am facing an issue where capsule cast is not detecting a mesh collider. This happens in very narrow scenarios and by my estimate this is only occurring around intersection points between mesh colliders.

The capsule cast passes through the mesh collider around its intersection point with another mesh collider. The intersection then occurs at the subsequent edge detected.

The capsule cast returns an invalid intersection point, calculating a gravity pass after this step causes the controller to fall through the surface.

I have conducted various tests for this controller and it works perfectly in any other scenario apart for this.

I examined in detail any part of the code that could be responsible for this, but after quite some testing I can assure that the problem is arising due to collision not being detected by Capsule Cast. I expect the capsule cast to provide accurate collision information.

I examined the mesh import properties and mesh collider settings, I also fiddled with Physics settings but the problem still persists.

This is part of the code responsible for the Capsule Cast.

Vector3 GetCapsuleCylindricalLength()
{
    return Vector3.up * (halfHeight - radius + skinWidth);
}

Vector3 CapsuleStart(Vector3 position) { return position + GetCapsuleCylindricalLength(); }
Vector3 CapsuleEnd(Vector3 position) { return position - GetCapsuleCylindricalLength(); }
float samplingRadius = radius - skinWidth;
float distance = velocity.magnitude + skinWidth;

Physics.CapsuleCast(capsuleStart, capsuleEnd, samplingRadius, velocity.normalized, out RaycastHit hit, distance, collisionMask)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745664798a4639058.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信