MackeyK24 Posted September 15, 2017 Share Posted September 15, 2017 What is the BEST way to move a camera by position... When using one of the built-in cameras ... you get good smooth movement... If I try to manually move the camera around using camera.position I don't get the desired effect. I can move the camera around using code like this (delta movements from input): public updateCameraPosition(camera: BABYLON.FreeCamera, horizontal: number, vertical: number, speed: number): void { if (camera != null) { var local = camera._computeLocalCameraSpeed() * speed; var cameraTransform:BABYLON.Matrix = BABYLON.Matrix.RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0); var deltaTransform:BABYLON.Vector3 = BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(horizontal * local, 0, vertical * local), cameraTransform); camera.cameraDirection = camera.cameraDirection.add(deltaTransform); } } but when I just try set camera position... its funny (I know that vague)... But it would hard to show with all the "Test Project Code" I am using to learn how to move a camera around "Unity-Style" Just wondering of simply setting camera.position (on a universal camera) should give me free range movement like a unity camera. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 15, 2017 Share Posted September 15, 2017 Hey I guess it is related to internia. By simply setting camera.position there is no inertia while using cameraDirection you will leverage the inertia engine. Does it make sense? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 16, 2017 Author Share Posted September 16, 2017 23 hours ago, Deltakosh said: Hey I guess it is related to internia. By simply setting camera.position there is no inertia while using cameraDirection you will leverage the inertia engine. Does it make sense? Not really... Still a newbie Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 18, 2017 Share Posted September 18, 2017 TLDR: Use cameraDirection Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted September 18, 2017 Author Share Posted September 18, 2017 1 hour ago, Deltakosh said: TLDR: Use cameraDirection I will try that... I have been having betting luck just sticking the camera in an empty mesh and moving the empty mesh around like they would move a camera transform around in unity... But I will try the cameraDirection method so not sooo kludgy using the empty mesh to move camera GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
jps0611 Posted September 1, 2018 Share Posted September 1, 2018 @Deltakosh how do you address the issue where you rotate the camera rotation? cameraDirection seems to be agnostic of the current active cameras rotation...how would you update the cameraDirection while also taking into account the cameras current rotation? For instance...let's say I rotate the camera 45 degrees....then I want to update the cameraDirection to move forward 100 units IN that direction. Any helpers in BABYLON to help calculate this? Quote Link to comment Share on other sites More sharing options...
Guest Posted September 4, 2018 Share Posted September 4, 2018 Well you can consider that your default direction is (0, 0, 1). so if you want to move forward you will need to add (0, 0, 100). And to take current camera rotation in account, you can simply transform this vector by BABYLON.Matrix.Invert(camera.getViewMatrix()) 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.