Player movement speed

I’m trying to make the player move, I’m using applyLocalImpulse, but the player starts moving very fast as he walks, how can I limit the speed?

applyImpulse make rigidbody have a speed instantly. So why not use setLinearVelocity to set is speed directly, It’s easier and more controllable.

This may work, but then the player will not walk in the direction of the camera

Why? If you set right speed, then player will walk in right direction.

This is not entirely true, the player now instead moves sideways and on one axis

OK. Anyway, you can directly modify linearvelocity after use applyImpulse to limit the speed of player, for example

    private speed = v3();
    private maxSpeed: number = 10;
    protected fixSpeed(): void {
        this.rigidbody.getLinearVelocity(this.speed);
        if(this.speed.length() > this.maxSpeed){
            console.log("fix speed");
            let rate = this.maxSpeed / this.speed.length();
            this.rigidbody.setLinearVelocity(this.speed.multiplyScalar(rate));
        }
    }