georage Posted July 12, 2016 Share Posted July 12, 2016 http://www.babylonjs-playground.com/#3HNIJ#1 I am trying to create a Fischer Price type toy with three meshes. I was thinking I could combine the three meshes and have one solid mesh and just move one mesh. Originally I tried connecting them with joints to give the character parts a little movement but the joints were way too loose. After creating and positioning my three meshes, whenever I try to make one mesh a parent it changes the location of the children. That seems very weird. Any ideas on how to combine these meshes? I tried another method (forget what it was called) and it said it was deprecated and to use child/parent. I want the option of making the meshes different colors too. Thanks for any tips. Quote Link to comment Share on other sites More sharing options...
JohnK Posted July 12, 2016 Share Posted July 12, 2016 Try setting parents before positioning. Quote Link to comment Share on other sites More sharing options...
georage Posted July 12, 2016 Author Share Posted July 12, 2016 (edited) Thanks, I figured it out. The trick is to make the lowest mesh the parent. Or at least that worked for me. I will try your method. It is very strange that children inherit the x and z values of the parent, but not the y value. It seems the values would be absolutes until the render loop runs. http://www.babylonjs-playground.com/#3HNIJ#4 EDIT: I tried JohnK's suggestion (setting the parent after creating the meshes but before positioning them and it did not work. The playground linked above is the only way I could get it to work. Edited July 12, 2016 by georage I tested JohnK suggested Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 13, 2016 Share Posted July 13, 2016 Hi again, g! http://www.babylonjs-playground.com/#3HNIJ#5 I tried a little parenting myself. In this animated version... http://www.babylonjs-playground.com/#3HNIJ#6 ...I am moving ONLY body1. Feet1 and head1 come along for the ride... due-to parenting. Anything seen there... that helps? Hope so. Quote Link to comment Share on other sites More sharing options...
georage Posted July 13, 2016 Author Share Posted July 13, 2016 Very cool Wingnut, thanks. Very helpful. I think part of my problem was trying to create the meshes at a non-zero spot ... i was creating the hockey players in their positions instead of at center ice. Changing the x and z positions of the meshes before parenting was rocking my brain! Quote Link to comment Share on other sites More sharing options...
georage Posted July 19, 2016 Author Share Posted July 19, 2016 Thanks to everyone's help I have this working reasonably well, but only the parent mesh seems to have collisions? Right now when the toy players fall over only their feet collide with other player feet. I would like the body and head to also give collisions. I tried adding impostors to the children in the makePlayer function but things got really weird ... the players started flying apart like the parts were exploding! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 19, 2016 Share Posted July 19, 2016 Summoning @RaananW Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 19, 2016 Share Posted July 19, 2016 Did someone call me? Physics? Yei! Parenting? YEAH! So, this is how it is done - http://www.babylonjs-playground.com/#3HNIJ#14 You set impostors to all of the child meshes, and then set an impostor to the parent. The parent then "removes" the other impostors and creates a single compound. Now the body1 impostor controls all three together. Click your mouse and see what happens when you apply impulse to the body. I noticed a small bug (which was not intended) regarding the physics impostors of the others (which are simply removed and not available), but that shouldn't stop you from developing your great game. Quote Link to comment Share on other sites More sharing options...
georage Posted July 19, 2016 Author Share Posted July 19, 2016 Thanks! I got collisions working on all the player meshes. Things are really bouncy still but I will play with the restitution values and see if I can tone it down. Thanks again! 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.