Hersir Posted March 22, 2017 Share Posted March 22, 2017 Hi just started to use babylon js Would like to have some sugestions on physics animaton. I have cylinder like mesh and inside in it is small sphere. I need to animate ball so that it push to border of cylinder and moves along it in cw direction, like centrifuge. Can i do it using physics? Till now i did it using posotion changes but as i need to slow down it would be nicer with some forces. One way I thought of is to calculate angle from center and apply impulse away from center and slighty forward but maybe there is better way. Quote Link to comment Share on other sites More sharing options...
wo997 Posted March 22, 2017 Share Posted March 22, 2017 As long as the movement is not very hard to code you can do it by simply setting position, it's your choice Quote Link to comment Share on other sites More sharing options...
wo997 Posted March 22, 2017 Share Posted March 22, 2017 or just use cannon.js it's simple to use, just ask me for more info Quote Link to comment Share on other sites More sharing options...
Hersir Posted March 22, 2017 Author Share Posted March 22, 2017 I would like to do it with physics. But it is not really clear how to add force so it moves along border of cylinder Quote Link to comment Share on other sites More sharing options...
wo997 Posted March 22, 2017 Share Posted March 22, 2017 @Hersir use @ to let me know about reply next time. first of all are you sure you need to apply force or can a body push each other? if not consider using applyImpulse https://doc.babylonjs.com/overviews/using_the_physics_engine#impulses-and-forces if you need to calculate the direction propertly ask me and I will show you how to do it using rotation matrix. Sorry if I didn't understand what you meant. Quote Link to comment Share on other sites More sharing options...
Hersir Posted March 23, 2017 Author Share Posted March 23, 2017 @wo997 Sorry for poor explanation. What I need is a mesh that is cylinder with hole in middle. So its looks like tube, and inside is one object , sphere. This sphere should accelerate in CW direction by applying force. Sphere is pushed to border of cylinder and hits it and rolls along it in CW direction. Quote Link to comment Share on other sites More sharing options...
wo997 Posted March 23, 2017 Share Posted March 23, 2017 @Hersir Consider making many jointed cuboids, can you image this arrangement? It's the only way to do it propertly, you need physics and rendering as well. Making them as one body can be a little challenge for you, I would use joints and I would place virtual cube in middle so it holds cuboids together. Quote Link to comment Share on other sites More sharing options...
Hersir Posted March 24, 2017 Author Share Posted March 24, 2017 I think picture will describe my idea better. I want to move sphere inside "bowl like object", using physics, I have working version for initial impulse that shoots ball and than it slowly slows down but I need to maintain speed till its ready to slow down (as slowdown need to happen on user interaction) so I need to re-add impulse in correct direction (tangential acceleration I think http://formulas.tutorvista.com/physics/tangential-acceleration-formula.html ) . But is it even possible to maintain constant speed with applyImpulse or applyForce? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 27, 2017 Share Posted March 27, 2017 Yes it is possible but perhaps you may not need to use physics and instead use your won code? Something like this:http://www.babylonjs.com/Demos/Facets/ Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 28, 2017 Share Posted March 28, 2017 Hi guys! Yeah, somebody else was goofing around with that, too. http://www.babylonjs-playground.com/#PBVEM#38 Version 42 is good, too... http://www.babylonjs-playground.com/#PBVEM#42 I bet that whole playground series is full of weird things. No 3rd party physics engines used... in those two. There IS a physics engine version somewhere around here. I think I saw someone put @RaananW's little physics-active car... in the bowl, too. And his cloth mesh got dropped into the bowl, as well. http://www.babylonjs-playground.com/#PBVEM#80 Ahh, there it is. That's the physics engine version... with the car, and the cloth, and the ball... all in the bowl. But, it's not working right now. hmm. Good fun. Hope this helps. Maintain perpetual motion, you say? Helluva challenge. 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.