Sign in to follow this  

FPS camera

Recommended Posts

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 !

Share this post

Link to post
Share on other sites


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 




Share this post

Link to post
Share on other sites

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 !



Share this post

Link to post
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.