Metalx1000 Posted June 12, 2014 Share Posted June 12, 2014 So I wrote this little script that has a Cube move from one empty to another to make it's way through a maze to another Cube.http://filmsbykris.com/scripts/Game-Basics/BabylonJS/Enemies/maze_2.html My question is, Can a get an object to follow a path/curve?I've tried Googling "babylonjs follow path", but didn't find anything.Is this possible at this point?Am I using the wrong wording in my searching? Thanks for any help. JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Kilombo Posted June 12, 2014 Share Posted June 12, 2014 It would be a good idea to define paths using bezier curves. This is quite powerfull, theres a tutorial. http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/ JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Metalx1000 Posted June 12, 2014 Author Share Posted June 12, 2014 Kilombo,So what you are saying is that there is currently no function in Babylonjs (as far as you know) that does this and if I want to do it I'll have to write my own function. Is that correct? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 12, 2014 Share Posted June 12, 2014 Correct. But check our roadmap, we have this point on it:) Quote Link to comment Share on other sites More sharing options...
Kilombo Posted June 12, 2014 Share Posted June 12, 2014 Hi Metal. I'm kind of a newbie on this, but has far has i know, there isn't, anyway.... It's quite easy to implement. I'll pass you the code I implemented in opengl 2 years ago, you just have to adapt to javascript. //varáveis da curva de besierGLfloat ctrlpoints[4][3] = { { 12000.0, 0.0, 0.0}, { 17000.0, 0.0, -12800.0}, {-9000.0, 0.0, 0.0}, {12000.0, 0.0, 0.0}};GLfloat besx,besy,besz;float tempo = 0.0f;//Calculo de cruva de beziervoid calculatePoly(float t){ int i=1; float a = -t*t*t + 3*t*t - 3*t + 1; float b = 3*t*t*t + -6*t*t + 3*t; float c = -3*t*t*t + 3*t*t; float d = t*t*t; besx = (ctrlpoints[i-1][0]*a + ctrlpoints[i][0]*b + ctrlpoints[i+1][0]*c + ctrlpoints[i+2][0]*d); besy = (ctrlpoints[i-1][1]*a + ctrlpoints[i][1]*b + ctrlpoints[i+1][1]*c + ctrlpoints[i+2][1]*d); besz = (ctrlpoints[i-1][2]*a + ctrlpoints[i][2]*b + ctrlpoints[i+1][2]*c + ctrlpoints[i+2][2]*d); }desenhaObj(2,besx,besy,besz,rotacao,3);The "desenhaobj" method receives has args the number of the mesh, besier position x, and so on, rotation (calcultated in another place) and the size of the mesh. Hope I've been helpfull. Quote Link to comment Share on other sites More sharing options...
Metalx1000 Posted June 12, 2014 Author Share Posted June 12, 2014 Deltakosh, good to hear.Kilombo, thanks for the help. I'll play around with this. MrVR 1 Quote Link to comment Share on other sites More sharing options...
celian-garcia Posted June 13, 2014 Share Posted June 13, 2014 Personnally I used TweenLite and TimelineLite to move my BabylonJs camera. There is a cool bezier plugin.Look at this example which inspired me http://codepen.io/GreenSock/pen/zcmpo. It was done with tweenMax which is'nt free but bezier plugin work also with tweenLite (free version). Quote Link to comment Share on other sites More sharing options...
celian-garcia Posted June 13, 2014 Share Posted June 13, 2014 Here is a little demo for you.http://jsfiddle.net/7hxQq/1/Hope it will help you ! Quote Link to comment Share on other sites More sharing options...
Metalx1000 Posted June 13, 2014 Author Share Posted June 13, 2014 thanks Kostar111 I'll play around with that. 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.