WiggleWizard / quake3-movement-unity3d

A port of the Quake III strafe jumping mechanics to Unity3D
286 stars 70 forks source link

Sliding Up Slopes #14

Closed arboulton closed 6 years ago

arboulton commented 6 years ago

Hello. I've been playing with this project a little bit lately and refactored some of it a little bit, primarily moving a couple of bits into fixed update so that the movement physics don't change depending on frame rate.

I'm encountering an issue where my character seems to be "sliding" up slopes. If I stand on a slope and push in a direction up the slope, the character will get stuck travelling in that direction until I return to flat land. If I had to guess it's something to do with the grounding detection, which seems to flicker on and off repeatedly and therefore might be repeatedly adding air acceleration on slopes? I'm not sure exactly how I might diagnose what is happening here though.

This is the segment I moved into FixedUpdate:

    private void FixedUpdate()
    {
        // In FixedUpdate to prevent rate of update scaling with frame rate
        if (_controller.isGrounded)
            GroundMove();
        else if (!_controller.isGrounded)
            AirMove();

        // Move the controller
        _controller.Move(playerVelocity * Time.deltaTime);
    }

Any suggestions for how to resolve this would be very welcome!

I'm drifting toward implementing my own isGrounded function to override the default charactercontroller one the script currently uses which I believe is simply a wrapper for if((controller.collisionFlags & CollisionFlags.Below) != 0) which would likely suffer from the physics issue of constantly being "pushed" out of clipping into the ground resulting in the isGrounded fluctuations. Perhaps a short raycast from a transform placed above the base of the controller, or something.

WiggleWizard commented 6 years ago

Better off just implementing your own isGrounded function to be honest, the standard one that comes with Unity isn't that fantastic to begin with.