Josh Miller Posted July 10, 2016 Share Posted July 10, 2016 http://babylonjs-playground.com/#RC9CZ Hello, I'm currently developing a small game and need to rotate a mesh to a point. I want to set the rotation of a mesh to face a specific point in the "3D-Room". I hope anyone can get this cylinder in the playground to face to (0|0|0). Thanks a lot, Josh Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 10, 2016 Share Posted July 10, 2016 Hi @Josh Miller, welcome to the forum. We were recently talking about "aiming an object" in another thread. Here is one of the playground demos we talked about. Let's do a docs search for 'rotation'... like this. Looks like link #1 and #8 might apply... for some delicious bedtime reading. In the above playground demo, you can see a nice function @line 63 called facePoint... looks pretty handy for you. Use at will. The cylinder has been created in a cone manner... no problem. Line 28 creates the cone, line 29 tips it on its side, line 30 elongates it, and line 31 applies the red material. You can disable cylinder position changes... by remarking-out line 137. Study that playground demo for a bit. Make changes, hit RUN over and over, SAVE new versions, but bookmark their new URL's so you know how to find them later. You can't hurt/overwrite ANYTHING important in the playground, so don't worry about pushing the wrong buttons. If you make a SAVE that you like or want to show us, paste it's URL into a comment, here. We're interested. If you need more help, holler. Again, welcome aboard. JohnK and Josh Miller 2 Quote Link to comment Share on other sites More sharing options...
Josh Miller Posted July 11, 2016 Author Share Posted July 11, 2016 Thank you so much for your help @Wingnut! I respect and honor your help for such a simple question I took this playground demo and removed the position part and added a sphere as a target. Updated Demo: http://www.babylonjs-playground.com/#Z3UOX#13 It would be awesome if the red spacecraft could face this sphere which is not on the ground. I have currently too little math knowledge for getting this done in the 3rd dimension Could someone help me? Quote Link to comment Share on other sites More sharing options...
adam Posted July 11, 2016 Share Posted July 11, 2016 http://www.babylonjs-playground.com/#Z3UOX#14 Wingnut and Josh Miller 2 Quote Link to comment Share on other sites More sharing options...
Josh Miller Posted July 11, 2016 Author Share Posted July 11, 2016 You Sir, should get a Medal of Honor. Let's raise our glasses to this active community! In eternal guilt, John. Quote Link to comment Share on other sites More sharing options...
le_fieber Posted April 30, 2019 Share Posted April 30, 2019 I needed something similar for a space sim game I do. I finally have some code which works quit well. The flying box is flying forward and rotates to the next waypoint while moving. Here is the playground: https://www.babylonjs-playground.com/#QFBT9R#19 Quote Link to comment Share on other sites More sharing options...
Guest Posted June 14, 2019 Share Posted June 14, 2019 We have a new forum: forum.babylonjs.com 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.