Snouto Posted January 4, 2018 Share Posted January 4, 2018 Hi I'm experimenting with Babylon and currently I'm trying to get a mesh (box) to follow a curve I've created. This part I've managed by borrowing various examples, but what i'd like to do now is make sure the box is always "facing" the direction of movement as it goes along the path. I've tried a few techniques I've found here and elsewhere but I seem to be having trouble making it work. Here's "my" code: http://www.babylonjs-playground.com/#5KA114#11 It's based on an example by @celian-garcia because I was planning on using TweenMax for this and some other animations I have in mind. Once I can get the above working I will then parent a camera to the box and use this as a fly-by-wire animation for my final scene. Would appreciate any help. Cheers Quote Link to comment Share on other sites More sharing options...
MarianG Posted January 4, 2018 Share Posted January 4, 2018 Take a look here Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 4, 2018 Share Posted January 4, 2018 Hi @Snouto and welcome to the forum. Sorry but I do not know how to use TweenMax. This uses BabylonJS animations https://www.babylonjs-playground.com/#92EYG#21 jerome 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 4, 2018 Share Posted January 4, 2018 After more study of your code I do not think there is any relationship between the position at tween.time(i) and p so position and orientation do not match tween.time(i); //jumps to the appropriate time in the tween, causing position.x and position.y to be updated accordingly. var orientation = new BABYLON.Vector3.RotationFromAxis(normals[p], binormals[p], tangents[p]); You need something like var rotationTween = TweenLite.to(rotation, quantity, {?????????}); and a rotationTween.time(i); as well as tween.time(i); Quote Link to comment Share on other sites More sharing options...
Snouto Posted January 4, 2018 Author Share Posted January 4, 2018 Thanks guys, I'll take a look at your advice. Your PG works really well @JohnK thanks for sharing! Quote Link to comment Share on other sites More sharing options...
SinhNQ Posted January 5, 2018 Share Posted January 5, 2018 Hope this help: http://www.babylonjs-playground.com/#5KA114#12 Snouto 1 Quote Link to comment Share on other sites More sharing options...
Snouto Posted January 5, 2018 Author Share Posted January 5, 2018 hey @SinhNQ thanks so much for this, a very nice update you've made there. Actually I couldn't get your version to run but I took the changes you made and put them in to mine and it looks great! I just now have to figure out how to make sure the camera - once parented to the box - looks in the correct direction and I'm just about there. Many thanks! Latest version Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 5, 2018 Share Posted January 5, 2018 Not quite right, loses tracking on tight bend. You can see the camera is following a box through the tube. https://www.babylonjs-playground.com/#5KA114#23 Also by adding an s to http:// ensures everyone can load your file "https://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js" ^ Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 5, 2018 Share Posted January 5, 2018 http://www.html5gamedevs.com/topic/21594-camera-boom-prototype/?tab=comments#comment-122980 Quote Link to comment Share on other sites More sharing options...
Snouto Posted January 7, 2018 Author Share Posted January 7, 2018 Thanks for the input everyone, I'm marking as solved as the answer from @SinhNQ addressed my needs. SinhNQ 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.