最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin5PV0评论

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)
Post a comment

comment list (0)

  1. No comments so far