When setting a parent to a box, the position goes wonky?

So I imported a corona Orb .babylon file and added a png texture to it. Then I wanted to use MeshBuilder.CreateBox to create a bounding box for it. If I set the new bounding box.position to equal the imported orb meshes position everything works great. But as soon as I set the boundingbox.parent to the imported orb it’s position goes way off into the distance. What causes this? How can I make my new box set to the orb center? My end goal is to clone this and then later on use collision detection on the bounding box to decide what happens to the orb. What is even stranger is that if I console.log(boundingbox.position) it says it’s right at the position I need it to be. Then If I clone the parent orb. I see a bunch of bounding boxes way of in the abyss.

Hello and welcome!
This may help: Use a Parent - Babylon.js Documentation

Hey DeltaKosh, I have spent countless hours pouring over the docs. This did not help unfortunately. For some reason as soon as I declare the orb as a parent of the box, this position goes +50 in the y-axis only. Not sure why? As soon as I remove the parent declaration the box is properly centered on my orb. I want to be able to link them so that I can do collisionDetection and decide to dispose of the orb and the bounding box when hit.

Ok understodd. can you repro on the playground?

and just to make sure, you are calling orb.setParent(parent) (which preserve the position) and NOT orb.parent = parent as stated in the doc right?

2 Likes

Oh gosh. This actually worked. I must have missed this. Thank you!