Tight Controls with physics

So I want to create super tight controls, specifically controlling the damping of x and y values.

Letting the x values have no damping which I solved, but having the y value allow acceleration as you fall. So here is the code as it is:

var MoveThis = pc.createScript('moveThis');
var x = 1000;

MoveThis.prototype.update = function (dt) {

    //Controls left and right movement.
    if(this.app.keyboard.isPressed(pc.KEY_D)) {
        
        this.entity.rigidbody.applyForce(x,0,0);
        
    } else {
        
        this.entity.rigidbody.linearVelocity = pc.Vec3.ZERO;
        
    }
        
    if(this.app.keyboard.isPressed(pc.KEY_A)) {
        
        this.entity.rigidbody.applyForce(-x,0,0);
        
    } else {
        
        this.entity.rigidbody.linearVelocity = pc.Vec3.ZERO;
        
    }
    
    //Press and hold space to ascend, but i'd rather it jump.
    if(this.app.keyboard.isPressed(pc.KEY_SPACE)) {
    
        this.entity.rigidbody.applyImpulse(0,50,0);
    
    } else {
        
        this.entity.rigidbody.applyForce(0,-1000,0);
        
    }
};

And here is the result.

You can see that the way I’m controlling the downward fall is manually and that is because the fall without is so slow based on the code I’m using for linearVelocity.

Let me know if you guys have any suggestions?

Have you tried playing around more with the gravity value in the settings?

Other than that, you can set world gravity to 0 and than manipulate the gravity force/linear speed just on the player to have a fine grain of control of the players movement depending on what they are doing (eg jumping up can be floaty while falling can be much faster).

I feel a lot of confusion is lack of info.

Like I understand your logic, I just don’t know how to manipulate the gravity.

Can you elaborate with a code example related to the engine. Thanks in advance!

There’s a global gravity setting in the project. (see section on gravity here) https://developer.playcanvas.com/en/user-manual/physics/