kurhlaa Posted February 4, 2018 Share Posted February 4, 2018 Hi, I try to use a Camera with a built-in movement (WASD keys). Default collision system allows to climb on small enough objects. However, if I look directly down and move forward to climb on the same mesh - it's impossible. PG - https://playground.babylonjs.com/#XKMVWE I think this is because camera.keysUp = [87] actually is not for "go forward", but for "go where your camera looks". That means that while looking down - key W tries to go through the ground. So power pushing me down is much more than needed to go up. This disallows me to move over almost any size of objects. Is there a switch to prevent moving Camera Up/Down with WS keys (or at least ignore camera's Y rotation when calculating a movement direction) ? If not - what else can I do? I could create additional JavaScript keys listeners for movement, but built-in way is so short and easy to use, I would like to keep it. Thanks! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 5, 2018 Share Posted February 5, 2018 Hi K. No solution, yet. https://playground.babylonjs.com/indexstable#XKMVWE#7 A little testing. I put red .ellipsoidMesh on camera, yellow .ellipsoidMesh on s1 (via my nasty .showEllipsoid() func). Then, I turned-on a renderTargetTexture for camera2... so I could use IT... to watch primary camera's red elllipsoidMesh... run over the yellow ellipsoid. Nothing solved, yet. Camera seems to sit atop obstacles fine... when upright. But, when camera forward vector is aimed downward... camera gravity might make cam ellipsoid... "rub-off" and fall to the ground. Increasing value of engine.collisionsEpsilon might help. Not sure. A post with no answers at all... by Wingnut. Figs, eh? heh. Sorry. Maybe this fancy playground will help us do further tests. And hopefully, others will comment soon. Keep in mind that the red camera.ellipsoidMesh (that gets added in showEllipsoid) is NOT parented to camera. It is kept POSITION and ROTATION-updated in lines 127-130. Although my camera.ellipsoidMesh tilts up/down just like the main camera, I'm not sure that the REAL camera.ellipsoid... tilts with cam. I think it does. This might be the issue. Perhaps the SIDES of a camera.ellipsoid have more "rub-off" tendency... than the tops and bottoms. So when you tilt cam face-down and try to sit atop an obstacle... camera gravity makes it slides off (onto the ground), AS IF the camera was constantly w-key-pushing against a horizontal obstacle. *shrug* Just some theories. Ain't it weird how camera.speed (line 63) MUST be around 4.0... or else the camera can't climb-over the obstacle? Interesting. Quote Link to comment Share on other sites More sharing options...
kurhlaa Posted February 5, 2018 Author Share Posted February 5, 2018 12 hours ago, Wingnut said: No solution, yet Is there a place to vote for a solution? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 5, 2018 Share Posted February 5, 2018 heh. Unfortunately, this situation MIGHT be limited by the way collider collisions are handled. Possibly un-avoidable. The "other solve"... would be invisible mesh... that camera sits-atop/within, and camera is parented-to it. AND, you know... you'd need to build your own invisible-mesh-navigating system. It wouldn't matter if you tilted the camera to face-down, because the invisi-mesh .ellipsoid is the one used... for "sitting atop another collider". You would never tilt the invisi-mesh... only the camera atop/within it. Cameras have an upVector. It is probably 0, 1, 0 by default. Let's pretend your camera is face-down. IF you then set the camera.upVector = new BABYLON.Vector3(0,0,-1)... I wonder if your W/S keys would change directions. Perhaps... you could nav-around a facing-down camera... exactly as-if it were facing forward. Worth a try, I suspect. Also, a forum and playground search for "upVector" might be fruitful. Some things to try. *shrug* 'POV' is another worthy search term. I'm not sure what POV is about, but it stands for "point of view"... I suspect. There are some POV things in BJS... but I don't know their story, or if they would be useful for you. Never used them. Might be a mesh-only thing... not for cameras. Possibly more useful if you change to invisible-mesh system. Talk soon. Quote Link to comment Share on other sites More sharing options...
kurhlaa Posted February 5, 2018 Author Share Posted February 5, 2018 upVector as I see changes how picture is rendered, where UP is. For example, you can set your LEFT as UP, and a whole picture will be rotated. I've modified a little your example - https://playground.babylonjs.com/indexstable#XKMVWE#8 Ellipsoid is a sphere now, so technically it's rotation shouldn't affect anything. Gravity is smaller too. Move close to the green mesh while looking down, and press S - you will fly Up, instead of going back. That means that camera's Y-rotation sets the movement Up/Down direction. I think the easiest solution would be to add a flag like camera.keysIgnoreYrotation, which will exclude Y-rotation from movement direction calculation. But this is just an idea, of course. Also docs say "The Universal Camera is now the default camera used by Babylon.js if nothing is specified, and it’s your best choice if you’d like to have a FPS-like control in your scene" - so developers at least have an idea of making a camera as main character (not invisible mesh) it would be nice to hear at least somebody, what plans do they have about this. 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.