How would I make it so if the shift key is pressed the mass of the rigid body decreases to a given value. BUT! if the shift key is released the mass switches back to its default.
I assume you already know how to detect a key press. You can change the mass of a rigidbody like the way below, I guess.
this.entity.rigidbody.mass = 100;
2 Likes
// initialize code called once per entity
Sprint.prototype.initialize = function() {
};
// update code called every frame
Sprint.prototype.update = function(dt) {
if(this.app.keyboard.isPressed(pc.KEY_SHIFT)){
this.entity.rigidbody.mass = 75;
}
else{
if(this.app.keyboard.wasReleased(pc.KEY_SHIFT)){
this.entity.rigidbody.mass = 100;
}
}
};
This is what I have so far, is this correct?
1 Like
Never mind it works
Thanks!