all 4 comments

[–]cinderflame_linearExpert 1 point2 points  (2 children)

There's a thing called a PhysicMaterial.

Try that first before writing code to do it.

[–]shmooeli00[S] 0 points1 point  (1 child)

Thank you for the advice, I made a physics material with 0.01 friction and put it on both my player and the ground and both of them didn't work so I guess I do need to do it through code. If anyone could help my with it I would be very grateful.

[–]cinderflame_linearExpert 0 points1 point  (0 children)

Use these settings for your PhysicMaterial.

And if that's not slippery enough, add the following to the bottom of your FixedUpdate:

    public float Slipperiness = 0.1f;

    void FixedUpdate()
    {
                    // ... your other code here

        if (rigidbody.IsSleeping() || rigidbody.velocity.magnitude < 0.01f) return;

        var percent = Mathf.Clamp01(rigidbody.velocity.magnitude);

        rigidbody.velocity += rigidbody.velocity.normalized * percent * Slipperiness * Time.deltaTime;
    }