Echnaton Posted October 30, 2017 Share Posted October 30, 2017 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 Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 30, 2017 Share Posted October 30, 2017 Hi, May I wonder why you don't use the collision detection functionality? Would help a lot. You can maybe try reproducing this simple behavior on the playground and we can suggest ways to solve it! Quote Link to comment Share on other sites More sharing options...
Echnaton Posted October 30, 2017 Author Share Posted October 30, 2017 This is what I try to ask. What is the best way to implement jump in a way that I can use the babylon collision detection functionality? Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 30, 2017 Share Posted October 30, 2017 Could this help? Quote Link to comment Share on other sites More sharing options...
Echnaton Posted October 30, 2017 Author Share Posted October 30, 2017 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? Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 30, 2017 Share Posted October 30, 2017 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. Quote Link to comment Share on other sites More sharing options...
Echnaton Posted October 31, 2017 Author Share Posted October 31, 2017 thank you for your reply. Then I will reduce jump distance so that the position remains in the elipsoid and babylon can calculate a push back. 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.