pepelito Posted May 28, 2017 Share Posted May 28, 2017 Hello guys, I have a little problem in my scenario. I am able to set the parent child relation among two meshes and i am able to move them along only if the parent mesh is dragged but not counter-wise. Both objects need to be able to be dragged and moved along together no matter which object is dragged. So i will be very thankful if anybody could help me. Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 29, 2017 Share Posted May 29, 2017 Interesting question. I would say that inheritance does not work in this case. I'm afraid you will have to do it manually. Perhaps make all objects inherits from an invisible root and always move this root when a child is dragged? Quote Link to comment Share on other sites More sharing options...
pepelito Posted May 29, 2017 Author Share Posted May 29, 2017 Hello, I tried this logic manually setting the position to the parent. It is okay but i dont know why the child is moving faster than parent... If you have any idea i would be very thankful Here is the code that i am using for setting parent position: currentMesh.parent.position.addInPlace(diff); where the diff variable is the change of position of the child mesh. Here is the result: http://buragev.website/Cannon/index2.html On image below: P - parent C - child Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 30, 2017 Share Posted May 30, 2017 This should work Can you try to repro in the PG with just simple boxes? Quote Link to comment Share on other sites More sharing options...
pepelito Posted May 30, 2017 Author Share Posted May 30, 2017 Hello, I solved my problem and here is the PG for that: https://www.babylonjs-playground.com/#11PS7J#1. The main logic that was applied can be seen on line 92. If the picked mesh has a parent, then drag the parent, instead. The problem before was that when the child is dragged than the parent is dragging the child once again and that's why the child was moving more than his parent. I must give almost all the credits to @Wingnut because he helped me a lot with my issue Cheers to @Wingnut and thanks to everyone. Hope that we will hang around more here! I will post my final game that i am working on when i will finish it, so i hope that you can see the final product soon. Cheers. Wingnut and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 30, 2017 Share Posted May 30, 2017 Yeah, we did a little behind-the-scenes talking, didn't we? I like you, pep. I hope we get to talk more. I didn't do much work on issue solve. I just borrowed Deltakosh's drag'n'drop demo... and did a little experimenting. Pep was able to make it work for his project... so... YAY! We scored yet another BJS victory. Pep's end-user is a pretty important institute, so BJS will be shining bright in a place with plenty of eyes. It's all good. Tell us all about the project, if/when you can, Pepelito. Good luck, visit often. Quote Link to comment Share on other sites More sharing options...
pepelito Posted May 30, 2017 Author Share Posted May 30, 2017 I like you too WIngnut, without you this wouldn't be solved probably The project is for National museum of Slovenia, so the visitors could play this game. I share the same thoughts that BJS will shine bright in a place with plenty of eyes ! Good luck to you too. Wingnut 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.