jps0611 Posted September 1, 2018 Share Posted September 1, 2018 Howdy, I'm building a custom camera controller using the CameraDirection and CameraRotation in order to preserve the inherent camera inertia. How the heck do I move the camera forward/backward using CameraDirection at the current Camera Rotation? Thanks! JPS Quote Link to comment Share on other sites More sharing options...
jps0611 Posted September 1, 2018 Author Share Posted September 1, 2018 Ah! Just simple trigonometry. For moving forward: camera.cameraDirection.x += Math.sin(camera.rotation.y); camera.cameraDirection.z += Math.cos(camera.rotation.y); Quote Link to comment Share on other sites More sharing options...
brianzinn Posted September 1, 2018 Share Posted September 1, 2018 Not as efficient, but you can also do some one liners with Vector3 Methods (untested): camera.cameraDirection.addInPlace( new Vector3(Math.sin(camera.rotation.y), 0, Math.cos(camera.rotation.y)).scale(forward ? 1 : -1) ); note: if you are building something to share, I think the Z needs to be inverse on right-handed scenes. jps0611 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted September 4, 2018 Share Posted September 4, 2018 Flagging as solved jps0611 1 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.