- Home /
Step Height without CharacterController
So I'm making a game, and I'm having an issue with colliders. My player has a box collider attached, along with a rigidbody (I'm handling input and most of the physics myself, because I wanted something more customisable and less realistic than Unity's built-in system). I cannot use a different collider type for various reasons. The game is quite high speed, and it all works perfectly fine so long as I'm on the terrain. However, I have a few cases where I move from the terrain to another collider (often other box colliders, occasionally mesh colliders).
This is where problems occur. It seems there is no leniency in the collider to allow it to transfer smoothly from one to the other (as the step height value achieves with character controllers). Instead, the player will just freeze in place, even when the difference in collider height is so small that it's almost impossible to see (even when zoomed in). I have tried creating my own step height algorithm by raising the collider slightly every time it enters a new ground collider, and this works to an extent, but the issue still occurs at low speeds, and when it does work, it causes a weird "bouncing" effect.
I believe the effect comes from the fact that colliders sink into each other slightly before registering a collision. I have tried to regulate this in the physics manager by setting "Min Penetration For Penalty" to 0.001 (I even tried it at 0, which didn't help at all), and "Solver Iteration Count" to 50. Can anyone help me to sort out this issue, to make transferring between "platforms" smooth?
Whenever I didn't use a box collider, this is what happened:
$$anonymous$$y character fell over
After my character's jump, it fell over
If I went up a ramp, my character fell over
$$anonymous$$y character would stutter up ramps, then fall over
$$anonymous$$y character would spin/rotate through objects
$$anonymous$$y character would hit the terrain collider, stop, start going forward again, and before it could it would fall through the terrain.
After about a month of this I decided that it would be smart to lock the rotation of a specific axis to make it impossible to fall over.
Box Colliders are a quick fix for the problem, sure, but understanding that they're limited in terms of movement is the first step.
I'm not one for giving out free codes (until my free package comes out that I'm working on), but If you lock one, or even two axis, and release them when you jump/fall/ whatever, you'll see a huge improvement.
I also use my own physics stuff, and I use a capsule collider.
This may not answer all of your questions, but using a character with a box collider will cause stutter-- most stutter in Unity is from colliders colliding with colliders. (That was ugly)
As far as the settings that you're changing: with my method I haven't changed any around and I have no problem walking up / with stutter.
After this, your question should be "How can I LI$$anonymous$$IT step height?" Still working on that one.
But my issue isn't the character falling over, it's the character literally SLIDING around on the ground. In fact, in order for my physics engine to work ALL rotation axis must be locked. There are other reasons why a box collider is most suitable. Also, I tried with a capsule collider, ignoring the sliding issue, and it did not fix the problem.
On another note, I did a bit more testing, and it seems I can fix the problem by INCREASING the $$anonymous$$in Penetration For Penalty. However, when I do so, the character sinks through the floor (which is of course expected), causing (other than the obvious graphical flaw) issues such as certain sounds not playing correctly, and trails made by my custom trail emitter to not work correctly. $$anonymous$$oving the collider down to counteract the change also counteracts the fix, so it seems I can have one issue or the other.
Hmm... So, since I've been handling physics myself, I've completely ignored Physic $$anonymous$$aterials. I decided to see what effect it had, and so I created one, with 0 static and dynamic friction, and 0.2 bounciness, and applied it to my character collider. The problem seems to have virtually disappeared, but I'll do a bit more testing.
I have found, with a bit more testing, that having some "bounciness" improves the issue, but doesn't remove it. I'm keen to keep the bounciness low, as it causes weirdness in other areas, so I'd still be keen for an alternative answer.
Having built some more of my level, it seems that this fix only happened to work in the circumstances I already had set up, so I'm back to square one again. I really do need help here. I can't seem to get any step script working either, as it's extremely difficult to tell when the rigidbody is prevented from moving in a specific direction due to a collision.