Because the default character controller is shaped like a capsule, whenever you run over an edge there’s a very annoying dip/bump that happens before gravity takes over. This happens because the bottom of the capsule is rounded so it crawls over the edge until there’s nothing to stick to, at which point gravity takes over. Anyone making a serious first-person game would want to get rid of that bump as part of polishing.
If we could change the character controller to a cylinder this wouldn’t happen, but we’re stuck with the unity capsule. Is there a tweak that gets rid of this, or some other work around?
I’m using UFPS as my first-person kit if there’s a solution in there somewhere.
Do you have any anti-viruses installed on your computer? Try Installing Malwarebytes Anti-Malware, Eset Smart Security, ADWCleaner and CCleaner. Might help if you run a scan on all of those.
I’m sure someone else is having this problem, so I’ll document my progress as I go.
One thing I tried is setting the player’s fall speed to the previous frame’s Y velocity when they become ungrounded. This makes sure the character’s falling speed doesn’t start at 0 when running over an edge which should mitigate or eliminate the bump.
While this did help mitigate the bump the character falls way too fast now, so it’s impractical. For reference here’s the simple code I was using (I’m using UFPS):
if (wasGrounded)
m_FallSpeed += lastVelocity.y * Time.fixedDeltaTime;
The next thing I’d like to try is placing a collider below the player’s feet when they start creeping over an edge to maintain them at a constant height. Then I can spherecast downward using the radius of the character controller to see if there’s any platform I would be clinging to (ignoring the collider under the player), and if not then remove the collider and get a nice smooth fall.
I’ll update again once I’ve tested this.
UPDATE:
OK I got rid of the ledge-bump!
Turns out the real reason for it isn’t the unity capsule but the anti-bump offset in UFPS, and I know the default Unity first person controller script has something similar called “m_StickToGroundForce”.
If you’re not familiar with either of these, this is extra gravity added to the character controller to make it go down slopes smoothly, otherwise the player’s momentum would make them fly off the slope if it was steep enough or you’d get bumpy movement going down a shallower ramp. The problem is this also makes the controller “sink” faster than gravity when it’s grounded and moving off a ledge, making the annoying bump before normal falling gravity takes over.
So the solution I used is to only enable anti-bump if there’s ground directly below the capsule with a raycast, and if not then disable it. So when the capsule is grounded but moving over a ledge, anti-bump gets turned off and I get a smooth fall over the edge.
It works great and I haven’t come across any exceptions yet.
Do you have any anti-viruses installed on your computer? Try Installing Malwarebytes Anti-Malware, Eset Smart Security, ADWCleaner and CCleaner. Might help if you run a scan on all of those.
– iAmAwsum