Bobomb peaceful-field First Person

hey im making a mario 64 bobomb battlefield but its after the battle so I want it to have toads and maybe even little missions but I need to know how to make my guy jump so I hope I can get some help with my game thanks

Hi @Lucious_Jansma,

Check this post on jumping:

Make sure to use the forum search function, there is plenty of material that can help you out.

1 Like

hey when i insert the script is there anything i need to change???

You are making me have dejavu, didn’t we have this conversation today again? :slight_smile:

ok sorry im just so confused do you think you could join my project to help me with the jump script mabye but its fine if you dont want to

I am away from my desk for tonight, but yes, add me (leonidas) and I’ll take a look tomorrow.

i did thank you thank you thank you.
and now for the hard part.
patience

Hey @Lucious_Jansma,

I had a quick look through your project, so the issue was the jump script you had in place was empty. You create a Jump script but there was no code in the script methods.

I’ve added the following code in the update method and now jumping works:

Jump.prototype.update = function(dt) {
    if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
        this.entity.rigidbody.applyImpulse(0, 1000, 0);
    }    
};
3 Likes

ohhh thank you my fault

what about the jump limit because i can jump indefinetly

You will have to enforce a rule to not allow jumping when your player is airborne. The proper way of doing this would be to do a raycast downwards for each frame and detect when your player is on the ground.

Allow jumping only when the player body touches the ground.

where do i find that?

You will have to code it, study some tutorials or example project that implement raycast on how it works.

Here are some:

https://developer.playcanvas.com/en/tutorials/?tags=raycast