jps0611 20 Posted September 1, 2018 Report 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 post Share on other sites
jps0611 20 Posted September 1, 2018 Author Report 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 post Share on other sites
brianzinn 373 Posted September 1, 2018 Report 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 post Share on other sites
Deltakosh 4315 Posted September 4, 2018 Report Share Posted September 4, 2018 Flagging as solved jps0611 1 Quote Link to post Share on other sites
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.