Pryme8 Posted August 14, 2016 Share Posted August 14, 2016 So I can totally do the normal ellipsoid camera movements and the same system as demonstrated by http://www.babylonjs.com/Demos/Espilit/ But Im really running into problems with making this handle like a real FPS controller, like with stepping over things, and how it handles slopes. What would be a better solution? a Ray casting system, or strap a simple object inside of like Cannon and do a mesh hit detection on a hidden capsule... Whats the best option? I want something smooth and dynamic. Quote Link to comment Share on other sites More sharing options...
mightymarcus Posted August 14, 2016 Share Posted August 14, 2016 Use the bullet physics javascript port. https://github.com/armory3d/haxebullet It's a haxe port, but you can find a javascript file ammo.js there. It's automatically ported from C++ to JS with Emscripten. It needs some time to get into it, but then you have first class physics. It's used btw in Blender. You can create a single physics body out of your terrain vertices data. If you want to try it I can show you how to use it, I played around a little with it and know how to make physic bodies out of indices and vertices. It's a little bit complicated first. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 14, 2016 Author Share Posted August 14, 2016 I should be able to figure it out, thanks boss! Any clue how to make a capsule mesh? Quote Link to comment Share on other sites More sharing options...
mightymarcus Posted August 14, 2016 Share Posted August 14, 2016 Hm. I would make one with blender and export as obj. Then you can get the indices and vertices with babylonjs and hardcode them to your custom createCapsule function. Something like that. Or you create a sphere and find the vertices in the middle and "stretch" it. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 14, 2016 Author Share Posted August 14, 2016 hmmm Im glad you decided to grace our forums, I like the way you think. mightymarcus 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 14, 2016 Author Share Posted August 14, 2016 http://pryme8.github.io/Magic_Marble/editor.html I forgot I did a physics controller for this... porting it over now for FPS. *UPDATE: So I need help... for some reason im drawing a mental block on how to get my speeds play into effect on the forward vector if(player_box.body.collisionResponse){ player_box.body.grounded = true; }else{ player_box.body.grounded = false; } if(player_box.body.grounded){ if(keys.w){ if(player.speed.f < settings.speeds.normal.f){ player.speed.f += settings.accel; }else{ player.speed.f = settings.speeds.normal.f; } }else if(keys.s){ if(player.speed.f > settings.speeds.normal.b){ player.speed.f -= settings.accel; }else{ player.speed.f = settings.speeds.normal.b; } } if(keys.a){ if(player.speed.s > settings.speeds.normal.s*-1){ player.speed.s -= settings.accel; }else{ player.speed.s = settings.speeds.normal.s*-1; } } if(keys.d ){ if(player.speed.s < settings.speeds.normal.s){ player.speed.s += settings.accel; }else{ player.speed.s = settings.speeds.normal.s; } } player.speed.f*=0.8; player.speed.s*=0.8; player.speed.u=0; if(player.speed.f<0.05 && player.speed.f > -0.05){ player.speed.f = 0; } if(player.speed.s<0.05 && player.speed.s > -0.05){ player.speed.s = 0; } var forward = v3(player.speed.s,0,player.speed.f).subtract(scene.activeCamera.upVector).normalize(); player_box.body.velocity.x = forward.x; player_box.body.velocity.z = forward.z; } This example lets you move around forward backwards ect correctly but does not take the cameras current forward into account. var forward = scene.activeCamera.getTarget().subtract(scene.activeCamera.position).normalize(); replacing forward with this, makes the direction of movement correct, but it is constant, and the speed restraints do not come into effect. forward.x*= player.speed.s; forward.z*=player.speed.f; but that makes things act really funky. any ideas? dbawel 1 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.