Jump to content

how to jump with collison detection


Echnaton
 Share

Recommended Posts

Hello

my camera has gravity and collision detection activated and keysUp, keysDown, keysLeft, keysRight set to move the camera. I implemented a jump that changes directyl the camera position:

this.jump = function() {
if(this.canJump() && jumpSpeed == 0) {
jumpSpeed = 0.60;
}
}

this.updateJump = function() {
if(jumpSpeed > 0) {
camera.position.y += jumpSpeed;
jumpSpeed *= jumpDeceleration;
if(jumpSpeed < 0.01) jumpSpeed = 0;
}
}

 

It basically works but it is not using the babylon collision framework. So it can accidentally jump through meshes above the head. Do you know a better way? Sorry for the bad formating of the code. I'm fighting with the editor function.

Regards echnaton

Link to comment
Share on other sites

Thank you for your answer.
I allready loked at that topic and if I understand it correct, it does what I do, increment the camera position. But when a mesh is to close overhead and the initial jump is to high, it jumps through the mesh to the invisible side. How can I prevent this by using the babylon collision detection?

Link to comment
Share on other sites

  • Echnaton changed the title to how to jump with collison detection

That's interesting! It shouldn't happen actually.

You need to make sure the camera's elipsoid is set correctly, you need to make sure the scene's collision is turned on, that the meshes have collisions enabled and that the camera has it too. If it is all set already, I would love to see a demo to be able to see how it can be fixed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...