Closed joshuacurtiss closed 10 months ago
What do you think about just expose vel
? This should enable most things
So you can just
// Accelerate falling when player holding down arrow key
onKeyDown("down", () => {
if (!player.isGrounded()) {
player.vel.y += dt() * 1200
}
})
// Jump higher if space is held
onKeyDown("space", () => {
if (!player.isGrounded() && player.vel.y < 0) {
player.vel.y -= dt() * 600
}
})
Hi @slmjkdbtl! Yes, exposing vel
would make me happy and would be more versatile. 🎉
vel
is exposed in v3000.1.17
!
Problem: When jumping with the
jump
function inBodyComp
, a force is applied but thereafter you can't change the velocity. What about if you want to: (a) Change the height of jump based on how long the player holds down the jump key? (b) Want to stomp down in the middle of a jump?Solution: With this function, you can accomplish the points mentioned above with a
jumpRelease
function that lets you change the velocity mid-jump.Example of use can be seen here:
https://www.curtiss.me/build-mario-with-kaboom/
(Notice how short or long jumps can be achieved by how long you hold the jump button, or stomping down by pressing down mid-jump)
How it is accomplished in the sample:
Thanks for your consideration.