Temptation Posted September 2, 2016 Share Posted September 2, 2016 Hello people, just got new to gamedev in general, read a lot here from babylon js forum and learned a lot of new things. But I got stuck and wasted almost 4 hours to find out a thing here but just cant. So my only option is to ask here I need to make Third person camera, and i got it working. Current implementation is, that I move my "player" regarding absolute location UP LEFT RIGHT DOWN And the camera forward direction is not taken in consideration. But what I need Is actually move the player forward regarding the camera forward vector. Can someone please at least give me the solution how to find camera FW vector ? Quote Link to comment Share on other sites More sharing options...
JohnK Posted September 2, 2016 Share Posted September 2, 2016 I can resist anything except temptation so must give an answer. Welcome. A search of this forum for the terms camera forward vector will lead you Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Temptation Posted September 3, 2016 Author Share Posted September 3, 2016 Oh yeah it worked, thanks As i didnt find a precise answer on my question, Ill make a post here describing : How to rotate a mesh based on camera forward vector. First we need to find out camera forward vector: var forwardVector = BABYLON.Vector3.Normalize(this.mesh.position.subtract(data.scene.activeCamera.position)); And then we need to find the rotation angle : var angle = Math.atan2(forwardVector.x, forwardVector.z) //And then rotate by Y axes this.mesh.rotation = new BABYLON.Vector3(0, angle, 0);; Thanks! Great forum, learned a lot in 2 days! Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 6, 2016 Share Posted September 6, 2016 Hi Temptation... welcome aboard. Or should I say... "welcome a billboard"? http://playground.babylonjs.com/#QKQHS#372 (line 56 - billboardMode... options available for X, Y, Z, or ALL) Your thing is in lines 63-65 (temporarily deactivated). Another fun thing is at line 68. BJS has lots of cool things to play-with, and lots of cool people. You seem to be one, too. Good to have you with us! PARTY!!! Temptation 1 Quote Link to comment Share on other sites More sharing options...
Temptation Posted September 10, 2016 Author Share Posted September 10, 2016 Hello, wow amazing demo. Thanks)) But I already achieved what was needed for me, I see your demo very usefull when doing enemy turrets or something:) This is what kind of movement I have currently. http://gph.is/2clIXGB Wingnut and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 10, 2016 Share Posted September 10, 2016 Beautiful! Well done. You have your camera move mode, and your vehicle move mode... perfect! 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.