Sign in to follow this  
kurhlaa

No collisions while jumping without physics plugins

Recommended Posts

Hello!

I try to implement jumping without included physics plugin. I've read so many topics, but without the result I want.

Here is a demo - http://www.babylonjs-playground.com/#YBAGYL

Please press RUN, left click to enable moving with arrows and mouse - try to jump with Shift on the red box - you will fall down through it, but I want to stay ON it. I think I've enabled all checkCollicions, gravity etc, but still no luck. What am I missing? Maybe my jumping implementation is bad. At this moment I don't want to use a physics plugin because I think it's an overhead for me - I need moving and jumping only from a character at the moment.

Share this post


Link to post
Share on other sites

The jump seems to be working correctly, but it goes through the mesh. Did I understand correctly? 

Your jump is an animation of the camera. During the animation, the position of the mesh will not be analysed so that collisions against the box would not be fully detected. Is that the problem you are describing in your playground?

Share this post


Link to post
Share on other sites
44 minutes ago, RaananW said:

The jump seems to be working correctly, but it goes through the mesh. Did I understand correctly? 

Your jump is an animation of the camera. During the animation, the position of the mesh will not be analysed so that collisions against the box would not be fully detected. Is that the problem you are describing in your playground?

Correct. The result I need - natural behavior when the character stays above the box. How can I achieve this? Why I use animations here - people say it's more smooth than changing Y position, but maybe it's fixable.

Share this post


Link to post
Share on other sites

The ideal solution would be when a character is not falling down through the mesh like in my example and when he can't jump higher than another mesh close above him (so the character is not moving up through it). I really hope it's possible without using a physics plugin

Share this post


Link to post
Share on other sites
Just now, RaananW said:

moveWithCollisions is your friend, I believe there were a few threads already about implementing a jump while checking collisions, but with mesh-to-mesh collision and not camera-to-mesh.Would mesh-to-mesh be an option?

Yes if I can look from inside of a character (like in FPS, like now) and potential other players will see me as a normal object.

Can you edit my example to help to achieve this?

Share this post


Link to post
Share on other sites

Just wanted to show a bit of a hack to make it work as well - http://www.babylonjs-playground.com/#YBAGYL#1

This will check if you collide against an object other than the ground and will stop the animation (making collision work again). This has a bit of a problem when you jump close to the box(or while touching it). But it is a work in progress :)

Still didn't try the moveWithCollisions thou.

Share this post


Link to post
Share on other sites
33 minutes ago, RaananW said:

Just wanted to show a bit of a hack to make it work as well - http://www.babylonjs-playground.com/#YBAGYL#1

This will check if you collide against an object other than the ground and will stop the animation (making collision work again). This has a bit of a problem when you jump close to the box(or while touching it). But it is a work in progress :)

Still didn't try the moveWithCollisions thou.

Hack works, a little :) But 3 problems:

1. As you said, you can't jump when you are next to the box;

2. Sometimes I get to see the inside of the box, probably sometimes an animation is interrupted in a bad position, somewhere in the middle;

3. Strangest one - while you are on the box and moving - you can't jump at all. You have to stop moving to be able to jump. Could be a bug.

 

By "work in progress" you mean soon it will be fixed in the babylon.js?

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.