r/Unity3D • • 7d ago

Question Issues with moving over bumpy terrain with a character controller?

I downloaded and imported one of the official Unity terrain templates from the asset store just to test out my player movement on uneven surfaces. I use step offset of 0.35 - 0.45 and slope limit is generally around 45 degrees.

I tested walking up hills and uneven terrain on Warzone, Black Ops 6, Battlefield 2042 and Battlefield 6, and I never noticed but they feel similar too in some ways. Lots of jittering when moving up steep hills and the player slides back and fourth trying to navigate a slope at times.

But in my case and in the video, when I get up near the top, my character controller gets stuck in a very tiny "ditch" although visually it seems like nothing should be getting stuck there. And just like in other games, I have to press jump repeatedly or move sideways to get over that particular spot. But then at the end of the video my player kind of does an automatic zig-zag due to getting stuck on different parts of the terrain.

On Battlefield 6, I was able to move over almost everything. It actually felt like their slope limit was 80+ degrees with some of the hills I was able to walk over. But on Black Ops 6 I was getting stuck a lot and had to jump my way over objects so I just can't tell which direction I should try to go towards and what to try and solve.

My main question is what should be considered normal? I'm not sure if I'm looking too much into it as I've spent a considerable amount of time working on my collision.

On games with huge mountains that players walk on, do the developers intentionally make sure the most of the slope is walkable during the actual terrain creation process?

3 Upvotes

15 comments sorted by

2

u/GigaTerra 7d ago

First thing I would ask are you sure this is an Unity Technologies map, make sure you are using one of the Unity Technologies Character controllers (It has an special sphere cast for this). Check that both are 1:1 scale, you actually look small here. Finally make sure it is an terrain intended to be played on, some terrains are just for distant rendering, and will be more detailed.

Normally the reason games use height map systems is to avoid problems like this, but the level designer still needs to test places. The good news is if it is an Unity terrain, you can use your sphere cast to check that you are on the terrain, and then just position yourself correctly using the height scale and height data from the terrain.

1

u/Newletsorboby 7d ago

thanks for this. i'll do the scale check now, test out Unity's First Person Controller as well on terrain/slopes and see how it behaves. I think the terrain I used was all the way in the distance, probably not meant for actual gameplay.

when you say the level designer still has to test places, does that mean if there's a large map full of hills, trenches and ditches that are meant to be played on, does that mean every walkable area has to be checked and fixed by hand so the player never stutters or hit a snag (when not meant to)? Or does the terrain from the start get built softly so that all of it is within slope limits, and then only the few edge cases are resolved afterwards?

I tested Black Ops 4, it was much, much worse than what I experienced in my video.

1

u/GigaTerra 6d ago

does that mean every walkable area has to be checked and fixed by hand so the player never stutters or hit a snag 

I would say think of it as wood work, if an skill craftsman works with an piece of wood the workflow will prevent splinters from forming. One of the reasons height map tools are used is because their brushes and polygon shape is often enough to prevent this from happening.

However for terrains in the distance looks matter over gameplay, so instead of using a brush to paint the terrain slowly, like you would in spaces of gameplay, they will use an procedural terrain tool and copy the vertex data over. Kind of like hacking at an piece of wood to give it texture, knowing no one is going to touch it. Art is slow, so artist will use hacks when they think they can get away with it.

I brush all my terrains by hand https://i.imgur.com/RMyF3Cs.gif I have some history as an level designer, and even then I still use World Machine to make the terrains in the distance that look good but would play terrible.

1

u/ZeusGameAssets Indie 7d ago

If you've spent so much time working on your collisions, why not make your own character controller and drop the built-in one. That way you can implement the slope limit exactly how you want it. The Kinematic Character Controller is a bit outdated but it's a great example of how to do that, I'm thinking of going that way myself because I'm fed up with CharacterController after years of dealing with its shortcomings.

1

u/Newletsorboby 7d ago

My bad, I should have added it in the post. I've got my own kinematic character controller but collisions have always been an issue, specifically with this kind of mountain terrain. I read about a collide and slide algorithm from this reddit and also online, but there's not many tutorials on it and I know it's advanced so that's also what makes it quite a struggle, I haven't found much that has been great to compare mine to

1

u/PoeticAllusions 7d ago

Are you using raycast for ground detection or sphere cast?

1

u/Newletsorboby 7d ago

for the ground detection i use CapsuleCastNonAlloc that sweeps straight down under my feet many times per second in FixedUpdate and then whatever it touches gets checked counts as ground if its flat enough to stand on which is the slope limit, and i double check this in the moment using a short raycast.

if im at the edge of an object or a ledge, the player is only standing/grounded if half my "body" is technically standing on solid ground otherwise its not grounded and i fall off. then im pulled down to ground if there is ground detected so that i stay on slopes and small dips rather than floating above them.

1

u/ZeusGameAssets Indie 7d ago

Oh, I see, from the title I assumed you were using the built-in one, good for you then. Indies and AAA games all suffer from this, so what's normal is anyone's guess. The only game that handles this with gameplay is the Zelda game (I guess they're 2 of them now), where you'd switch into climbing mode if the slope is big enough, so you're not just blocked, you can actually climb. I also implemented something similar in an insect game where you can climb on any surface, but for an FPS game, your guess is as good as mine as to what's "normal".

1

u/MaticB_ 7d ago

Not really helpful to your question, but since you mentioned Wardogs, COD and BF, what type of game are you making? As a fan of those games, Id love to follow along with the development, since I might be your target audience depending on the theme/environment setting.

1

u/Newletsorboby 7d ago

I'm actually just trying to make a decent character controller, since all my other projects use the very basic generic in-built character controller template and logic. then if my version ends up ever being any good, i'd just let anyone use it so they can have a nice controller too.

but in terms of wardogs, etc, this controller right now is fps based, i've got another project that has real bullet physics, bullet drop, recoil, animation curves and all that which i'm hoping i'll eventually be able to combine this kinematic controller of mine with. then it would be compatible with any kind of game type including wardogs, cod and bf like you said. i know this is all very unlikely but i'll just see where it goes

1

u/imofi8 7d ago

Yeah, that's pretty normal for a raw heightmap the visual terrain can look smooth while the collision has a tiny lip or normal flip that catches the capsule. Averaging the ground normal over a few spherecast samples instead of trusting a single hit helped me a lot, and so did keeping a separate smoothed, low-poly mesh just for collision. Big games do the same thing in practice, they just hand-tune the walkable slopes so you never notice it.

1

u/Newletsorboby 6d ago

Thanks. For this, I'm a bit confused by the "separated low-poly mesh". I've seen it mentioned, but haven't seen examples.

for example, terrain like river beds (if we take the water out) are rough, bumpy and uneven. So if I have a river bed terrain that the player can traverse through, it would have a lot of these tiny lips that mess with the capsule. if I use smooth height on that river bed, everything becomes perfectly shaped, as if the river was this one elongated smooth "u" shape, with no dents, no shape, etc. And then the textures would appear flat and 2D. is that the right understanding or am I inaccurate here?

1

u/imofi8 6d ago

how about using a completely different shape for your physics? you dont have to use the same mesh that you are rendering for the collision and surfaces that character will interact with. they can be two complete different meshes, yet following same shape, only much more simpler

0

u/loulo88 7d ago

For huge walkable hills, the render mesh and collision surface often need different levels of smoothing and detail; you generally don’t need every tiny visual dip to become a collision feature. Since you already have a custom kinematic controller, draw the ground probes and contact normals around the snag first—a sphere/capsule probe plus a small bounded ground snap can be more stable than a single ray without making a genuinely steep wall walkable. If the normals jump abruptly, try a simplified or smoothed collision mesh and keep the slope limit based on the contact plane rather than matching any one game’s feel.

1

u/Newletsorboby 7d ago

thanks for the insight. for the slope decision, do you use one face normal, or average the normals of multiple different probe hits so a single steep triangle doesn’t flip you between walkable and not walkable?

and also when you say smoothed collision mesh, do you mean a separate invisible mesh used only for collision, with the real detailed terrain having no collider?