Javierl Posted February 28, 2017 Share Posted February 28, 2017 Hi everyone, I'm very new to BabylonJS and to building games in general. I've read lots of resources and tried lots of things and I still don't quite know what I'm doing, to be honest but I've stumbled upon this noob question, hopefully is an easy one, even though it's not so obvious for me. So, I'm trying to build a game in which there is a character that can move around the scene. I've got a friend that is creating cool buildings with Solid Works and exporting them to STL. Managed to import them (not with pain) to BabylonJS, but then got in a bit of trouble making the character "interact" with the building (ie, a castle, I've imported it as a Mesh, should I import it as scene? by the way? what would be the difference?). Anyway, first of all, I understood that you have "two ways" of dealing with this, either using physics, or collisions. I tried first with "collisionsEnabled" and "moveWithCollisions", and I almost managed to achieve what I was looking for. My character could move and would collision with the castle, I could get in through a whole (door), and all fine. The issue comes when there are stairs or a ramp, I haven't managed to get the character walk through them. I did a lot of research and came up with the conclusion (please tell me if I'm wrong) that using moveWithCollisions wouldn't work for my purpose as without using Physics, Babylon doesn't distinguish between a wall or a stair/ramp, it's all a collision and hence the character cannot keep walking. Please tell me if I'm wrong with any of this. So, I tried to enable physics and this is where the magic begins... my building and the character were falling through the ground, and lots of crazy stuff, I'm obviously doing something really wrong. I kind of managed to move a box towards the building but it seemed to collision very soon with the castle and I've been unable to test if it can go inside the castle and through the stairs because as soon as the character gets closer to the building it does some crazy jump and disappears, I suspect might be related to the fact that I've set the castle as a BoxImpostor but I'm not really sure and still not very sure if I'm doing the right thing switching from using collisionsEnabled to enabling physics and using Oimo or Cannon, which I also heard that are way more realistic but at a performance cost. That's it pretty much, I've spent endless hours and haven't made any progress, so thought of asking for advice before investing more time to ensure at least I'm on the right track. Any advice would be very appreciated. Thank you! Regards Javier Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 28, 2017 Share Posted February 28, 2017 7 minutes ago, Javierl said: using moveWithCollisions wouldn't work for my purpose as without using Physics, Babylon doesn't distinguish between a wall or a stair/ramp, it's all a collision and hence the character cannot keep walking. Hi! So, you are wrong on this one . If you want to see a nice example, check the espilit demo - http://www.babylonjs.com/Demos/Espilit/ . It is all a matter of setting the camera's ellipsoid correctly and the steps in the right size. Adding physics would be a very interesting task, as you would need to start moving with forces and velocities. This is a hard (and a very rewarding) task. I would stay with the simple collision system. If there is a physics usecase in your game, you can combine the two. But it really depends on the usecase. Quote Link to comment Share on other sites More sharing options...
Javierl Posted February 28, 2017 Author Share Posted February 28, 2017 Hi RaananW, Thank you for your reply! I've seen that demo before, sorry I probably didn't explain myself properly I am not trying to do a FPS, but a third person, ie, you can see the character in the middle of the screen, the camera is on top. Is this still posible with "moveWithCollisions"? Can I apply an ellipsoid to the mesh/character? Haven't been able to find a working example of that. Re: Physics, I indeed applied angular velocity to the character and managed to move it like that, but seems a much more complex task, so I think I'll try to stick to moveWithCollisions, if I manage to get this to work. Cheers, Javier Quote Link to comment Share on other sites More sharing options...
Javierl Posted February 28, 2017 Author Share Posted February 28, 2017 Finally I got it to work (not sure how! haha) by playing with the mesh ellipsoid and the player speed, thank you for your help! GameMonetize and RaananW 2 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.