I know this question was addressed in this post. But the difference in my case is I am creating dynamic characters. I have made a change so that the capsule collider that is added to the character uses the SkinnedMeshRenderer's bounds to determine the center and height of the capsule collider. This way it correctly matches the size of the character. This results in issues where my characters gets stuck as soon as they run into a wall. It happens the exact same way as the previous post mentions. There is only one collider on the character (the capsule collider) and it is not clipping inside the wall or anything weird like that. I have also tried setting the AllowRootMotionPosition and AllowRootMotionRotation to false but it changes nothing. Any ideas?
Here is the code I use to setup the character dynamically:
And this is the code I've changed to set the capsule collider based on the mesh:
I have tried multiple different center and height values but they end up with the character being partially in the floor or the collider height just doesn't make sense.
Here is the code I use to setup the character dynamically:
C#:
CharacterBuilder.BuildCharacter(gameObject, new GameObject[1] { playerObj }, true,
new RuntimeAnimatorController[1] { playerAnimator.runtimeAnimatorController }, string.Empty, ControllerType,
false, new GameObject[0][], null, false);
CharacterBuilder.BuildCharacterComponents(gameObject, false, false, null, null, false, true, true, playerAnimator.isHuman, false, false);
var characterLocomotion = gameObject.GetComponent<UltimateCharacterLocomotion>();
MakeRagdoll(playerObj);
AddAbilities(characterLocomotion);
var camera = CameraUtility.FindCamera(gameObject);
if (camera != null)
{
var cameraController = camera.GetComponent<CameraController>();
if (cameraController != null)
{
cameraController.Character = gameObject;
}
}
And this is the code I've changed to set the capsule collider based on the mesh:
C#:
var meshrenderer = character.GetComponentInChildren<SkinnedMeshRenderer>();
capsuleCollider.height = meshrenderer.bounds.size.y;
capsuleCollider.center = meshrenderer.bounds.center;
capsuleCollider.radius = 0.4f;
I have tried multiple different center and height values but they end up with the character being partially in the floor or the collider height just doesn't make sense.
Last edited: