Handling LayerMasks on terrain?

I am trying to find out if there is a way to have multiple LayerMasks on a single terrain object or what the workaround would be for that.

Right now I have player movement using a SphereCast based on whether I am standing on a flat surface or on a slope (for slope sliding) and I have Layers for both which are Ground and Slope. If I am standing on a flat surface, then the Slope Layer can never function.

But on a terrain object because there’s only one option for a Layer, how would I separate flat ground and slopes if I decide to use the Paint Terrain option and raise terrain to form a few hills/mountains? At the moment there are a few brief instances where my player stutters where the flat ground and slope first meet at the base.


In this photo the only solution I can think of is adding invisible box colliders between the slope/tall hill to the left and my player so that technically a wall is detected as opposed to a slope.

I would not use layers for this. Better to use raycasts and use the normal of the output RaycastHit to calculate the angle of the ground under the player.

Thanks for the reply. Wouldn’t that only partially work because the Raycast doesn’t have the 360 degrees range that the SphereCast does so it would stop detecting angles near the bottom of hills/slopes/mountains etc while the player is still technically on an angled surface?

9515512--1341460--upload_2023-12-7_12-40-46.png

But then using a SphereCast also has its own issues like in my post where it’s detecting angles when and where it should not so I’m stumped.

I did say raycasts, plural. You can use more than one.