Steep Slopes Cause A Stepping Like Motion

There is an issue I noticed in which when traveling down steep slopes the character sort of looks like they leap a bit in the air.
Is this a due to a lack of mass on the character or is there something else?
Maybe this is fixed in a latter lecture?

This is caused by the CharacterController returning false for IsGrounded when travelling down a steep slope.
Try adjusting the Slope Limit in the CharacterController (and possibly the step offset).

This is a bit of a hack and doesn’t solve the problem.
I set the step offset to 0 and still had the same problem, this also means I can’t walk up steps.
Reducing the slope would also mean that if I have a slope exceeding that limit and I wanted the player to go up it they wouldn’t be able to

Actually, I was thinking more along the lines of increasing the slope.

Hey Brian
Thanks for trying to help unfortunately it still doesn’t really solve the issue.
Basically it looks like the Character moves too far forward on the slope and then gravity kicks in.
I might play around with the Fixed and Late updates and see if these help

Let’s take a look at your ForceReceiver.cs. That’s our gravity in this particular game.

This is my Force receiver, it should be more or less similar to the lecturer

public class ForceReceiver : MonoBehaviour
    {
        [SerializeField]
        private float _drag = 0.3f;

        private CharacterController _controller = null;
        private NavMeshAgent _navMeshAgent = null;

        private Vector3 _impact = Vector3.zero;
        private Vector3 _dampingVelocity = Vector3.zero;

        private float _vertVelocity = 0;

        public Vector3 Movement => _impact + Vector3.up * _vertVelocity;

        private void Awake()
        {
            _controller = GetComponent<CharacterController>();
            _navMeshAgent = GetComponent<NavMeshAgent>();
        }

        private void Update()
        {
            if (_vertVelocity < 0 && _controller.isGrounded)
            {
                _vertVelocity = Physics.gravity.y * Time.deltaTime;
            }
            else
            {
                _vertVelocity += Physics.gravity.y * Time.deltaTime;
            }

            _impact = Vector3.SmoothDamp(_impact, Vector3.zero, ref _dampingVelocity, _drag);

            if (_impact.sqrMagnitude <= 0.2f * 0.2f && _navMeshAgent != null)
            {
                _impact = Vector3.zero;
                _navMeshAgent.enabled = true;
            }
        }

        public void AddForce(Vector3 force)
        {
            _impact += force;
            if (_navMeshAgent != null)
            {
                _navMeshAgent.enabled = false;
            }
        }
    }

This looks correct. All I have different is Jump, which it’s likely you haven’t gotten to you yet.

How steep of a slope are we talking about? Can you provide a screenshot or better yet a video of what’s going on? There are some slopes that simply aren’t going to be smooth with the characterController.

Here’s an image of what I’m talking about

So on a fairly extreme slope… I think what’s happening is that the character is moving forward faster than gravity is pulling it downward. Short of increasing gravity, I can’t think of much more to do. Note that for most humans, attempting to move quickly down a slope of 45 degrees ends in a tumble to the ground (google “Chasing a cheese wheel” and see what a group of crazy people will do on a 30 degree slope). :slight_smile:
I quite literally take pains to ensure that my characters can’t get to a spot like that in the first place. (obstacles, colliders, etc). That’s partly because of the crazy slopes, and partly because I don’t want them up on the cliff tops)

Yea figured that was the issue.
I still might play around and see if there is a way around it but otherwise thanks for your time Brian

Privacy & Terms