Pryme8 Posted March 11, 2016 Share Posted March 11, 2016 So I know how to get the forward vector: var forward = scene.activeCamera.position.subtract(gameSettings.playerObject.position).normalize(); forward.y = 0; but how does one go about getting the left vector? I can apply an impulse playerObject.applyImpulse(forward.scale(-0.05), playerObject.position); and effectively push the object away from the camera, but how would I "push" from the left of the object or the right of the object in relation to the camera? ***EDIT*** I thought about it and it dawned on me... cross the up vector of the camera with its direction... var forward = scene.activeCamera.position.subtract(gameSettings.playerObject.position).normalize(); var right = BABYLON.Vector3.Cross(forward, scene.activeCamera.upVector).normalize(); right.y = 0; Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 13, 2016 Share Posted March 13, 2016 Correct!! A simple cross can make it 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.