I've been looking around the Internet to help set my character's speed to a maximum - basically, putting an upper limit on its horizontal speed. The best thing I've found so far is this:
rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -maxSpeed, maxSpeed), rb.velocity.y);
The main issue with this, though, is that this prevents the character's actual velocity from going past whatever maxSpeed is set to (let's say 4), meaning that if, say, it is hit by a moving object that would push it so that its horizontal velocity would go past 4, whenever movement calculations are done, it would be reset to 4. What I am looking for is something that would prevent the character from accelerating on its own past 4 but that would still allow it to move with external force.