I’ve created some animations in Blender and exported them to Unity. However, I’m running into some collider issues. With my run animation, the capsule collider is lagging way behind the mesh. Is there a way to fix this?
Here’s what it looks like. Thanks in advanced for any help.
Lots of things to consider here, but the simplest and most easily implemented would be to simply take out the forward movement from the animation you added.
Don’t want a run animation to move the “center of gravity” or the root bone of your animation, forward/ backward movement should be achieved with actual translation of your game asset.
Beyond this, you could move this collider to the waist bone, but that could cause erratic movement with rotations.
Another solution would be to move the collider to the position of a key bone in your rig, but have it ignore the rotation, but this could interfere with force values if you’re using physics to move around.
You could try adding a sphere to the waste bone to sorta check for collisions independent of the main capsule collision, but you’d have to do some new collision layers and get that all up and running.
Truth is, there isn’t a super simple solution, but your best bet is probably to keep it as simple as you can. So again, easiest and surefire thing you can do for now is redo the animation in a way such that the center of mass is over the vertical axis at the origin, then the next issue will be figuring out how to get the acceleratino to work properly so that they don’t look like they’re sliding around when walk animations start.
If it sounds like there isn’t an easy or straightforward solution, it’s because there isn’t. Character controllers are a pain in the butt, especially if you’re starting out. You might consider looking into some tutorials that cover the entire process.
Are you using root motion or no? In any case, it does look like your animations are a bit far forward with respect to the root. Maybe try to pull the character back in your animations, and the root should be inline with the player’s body/center of gravity in the animation.
Are you using ‘use root motion’ in your animator component? (Uses the motion of the animation to drive the character game object movement). I would recommend trying not using that and instead either driving the Charactercontroller component (see docs) or using a capsule and rigid body and using MovePosition and MoveRotation. Those approaches mean your animation plays ‘on the spot’ but you control the speed of the character to match. Remember you can also tweak the speed of the animation clip in the inspector for your animation state if you need to match foot placement to speed.
Thanks for the response. I deliberately didn’t move the root bone to try and avoid this issue. I did move the hip bone forward, though, so I’m assuming that’s going to have the same effect? Movement or rotation of the hip bone is going to stop the collider conforming to the mesh?
If so, I think you’re right. I should probably just redo the animation.
Yeah, in general (BIG in general here), keep the root and the hip bones aligned. For animations like a run/sprint where the player is leaning forward, you can rotate them at the hip, keeping that centered on the root. Side to side movement is of course, fine and expected for a walking/running animations.
This is of course generalised to those sorts of animations. You will need to break this practice for other kinds, potentially.