kurhlaa Posted November 29, 2017 Share Posted November 29, 2017 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. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 29, 2017 Share Posted November 29, 2017 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? Quote Link to comment Share on other sites More sharing options...
kurhlaa Posted November 29, 2017 Author Share Posted November 29, 2017 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. Quote Link to comment Share on other sites More sharing options...
kurhlaa Posted November 29, 2017 Author Share Posted November 29, 2017 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 Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 29, 2017 Share Posted November 29, 2017 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? Quote Link to comment Share on other sites More sharing options...
kurhlaa Posted November 29, 2017 Author Share Posted November 29, 2017 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? Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 29, 2017 Share Posted November 29, 2017 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. Quote Link to comment Share on other sites More sharing options...
kurhlaa Posted November 29, 2017 Author Share Posted November 29, 2017 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.