Adrian Posted September 13, 2014 Share Posted September 13, 2014 Hello folks ! I recently discovered babylon.js and it's awesome ! I would like to create a FPS camera, i mean a camera that doesn't need to click on screen to move ! Can you help me with pieces of code ? Many thanks ! Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 13, 2014 Share Posted September 13, 2014 Hello,var camera = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(0, 1, -15), scene);scene.activeCamera = camera;scene.activeCamera.attachControl(canvas);scene.activeCamera.keysUp.push(87); // Wscene.activeCamera.keysLeft.push(65); // A scene.activeCamera.keysDown.push(83); // S scene.activeCamera.keysRight.push(68); // D Tutorial:https://github.com/BabylonJS/Babylon.js/wiki/05-Cameras Welcome Quote Link to comment Share on other sites More sharing options...
Adrian Posted September 13, 2014 Author Share Posted September 13, 2014 Thanks dad72, but i still have the same problem. I have to click and hold the click to move the camera .... Quote Link to comment Share on other sites More sharing options...
Adrian Posted September 13, 2014 Author Share Posted September 13, 2014 I think i have a start for my problem i used : engine.isPointerLock = true;But when the mouse leave the browser the camera doesn't move anymore ... Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 13, 2014 Share Posted September 13, 2014 But when the mouse leave the browser the camera doesn't move anymore ... This is a normal behavior. Quote Link to comment Share on other sites More sharing options...
Adrian Posted September 13, 2014 Author Share Posted September 13, 2014 Nothing to do about that ? To have something more fps like? In fact, what i want is not a camera based on mouse pointer but a camera which move when i move mouse. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 13, 2014 Share Posted September 13, 2014 I believe that this is possible with the camera rotating, but I'm not sure. may be that deltakosh will be able to tell you more has this subject. You can also try all cameras here : http://www.babylonjs.com/playground/#1SGRQM Quote Link to comment Share on other sites More sharing options...
Adrian Posted September 13, 2014 Author Share Posted September 13, 2014 I have tried VirtualJoystick, that's what i need. But i need to combine it with keys. Quote Link to comment Share on other sites More sharing options...
davrous Posted September 13, 2014 Share Posted September 13, 2014 Hi, This is quite simple to do, we can put it on our to-do list. The only problem is that this feature only works inside Firefox & Chrome and we're usually writing features that work everywhere.David Quote Link to comment Share on other sites More sharing options...
Adrian Posted September 13, 2014 Author Share Posted September 13, 2014 Hi david. I'm very new to babylon so my question is maybe stupid but can i put some code on in the render loop to adjust the position of the camera according to my mouse? Here is an idea : When i create my scene i record x and y from my mouse pointer. Then in my render loop i check if i moved left, right, top or bottom and change my camera settings according to this. Is it possible ? How can i change my camera programmatically ? English is not my native language, let me know if i'm not clear enough ! Thanks Quote Link to comment Share on other sites More sharing options...
Adrian Posted September 13, 2014 Author Share Posted September 13, 2014 Ok, i found the solution, just need time to write something that work ! EDIT : Is it possible to have a free camera without rotation using mouse? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 15, 2014 Share Posted September 15, 2014 Hey guys, it is already working Just launch a scene in fullscreen using Chrome Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 15, 2014 Share Posted September 15, 2014 This will also work in an upcoming version of IE 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.