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?