I’m trying to create a solution to the device orientation camera. Where you will have a on screen joystick and the y axis will move the camera in the forward direction (the way it’s looking) and the x axis of the joystick will move right and left (from the way you’re looking) I’ve got this to kind of work using camera.positon but then I run into walking through walls as physics are not taken into account.
So can someone help me with a solution to two problems? Updating the camera position with collisions and also solving the joystick issue to always move the camera along it’s local transforms. This is what I have so far:
Hi I73. There’s always the down’n’dirty “proxy” method. This is where you parent the cam… to an invisible sphere (with .checkCollisions=true). Then, when joystick moves, use moveWithCollisions on the invisble sphere, and perhaps the camera will ride-along?
Or… (instead of parenting) you can set camera.position = invisisphere.position… onBeforeRenderObservable.add(here)
(in other words, constantly)
Either way, make the cam go where the invisi-sphere is located, and make the joystick do invisi-sphere.moveWithCollisions()… maybe? Just some early ideas. Stay tuned for others.
Late thought: There is one other STRANGE possibility. IF you are using a freeCam with applyGravity = true… then your joystick COULD set scene.gravity X and Z values… which are normally set to zero. IN THEORY… if your joystick LEFT action… sets scene.gravity.x = -5… the camera SHOULD slide to the left. Release joystick, return scene.gravity.x to zero… camera should stop… maybe after a bit of inertia scrub-off. No moveWithCollisions or proxy invisi-spheres… with this goofy idea.
You’ll never guess what I found: https://www.babylonjs-playground.com/#KX33X8#105
lol!
I updated line 219 box.moveWithCollisions(new BABYLON.Vector3(diffX/20, 0, diffY/20)); how would you suggest to update that to continue to move it every frame and not just by the coords of the 2D texture?
Oh, yeah, a GUI version of VJ. (sorry, I’m slow). Yeah, that thing smokes! Good find!
I’m bookmarking that puppy.
That first URL you sent… is GUI, too. At first sight, I thought it was old virtual joysticks thing. But no… and I’m the one that coded the damned thing (105) using stolen code. Memory fail.
notice how when you apply a force to the player the scenes gravity will change. this way you can use scene.gravity as the velocity variable for the player/camera. for meshes, you can make and use a separate variable as .moveWithCollisions() is available for them.