PolygonMeshBuilder Rotation

I’m building a simple game where there is a player on the ground and the player have to pass through the incoming obstacles which have holes in it.

I created the obstacle with PolygonMeshBuilder and added hole to it, now I have to change the orientation of the obstacle so that it will look like a proper obstacle for my game

If you see my game scene in playground the obstacle is overlapping on ground.
How to add proper rotation to the obstacle so that it will stand on the ground?

playground link: Babylon.js Playground

It would be really helpful if someone helps me in solving this

Welcome ! The rotation center of your new mesh has moved to a corner. So it’s very different from being in the center. You can see this using gizmo or inspector.
swastik rotation center | Babylon.js Playground (babylonjs-playground.com)
or use pivot change the mesh’s rotation center.
Pivots | Babylon.js Documentation (babylonjs.com)

Thank you so much for the quick reply @musk.

If possible can you explain below lines like how did you arrive at these values for position and rotation

    polygon.position.x = -5+10;
    polygon.rotation.x = Math.PI*1.5;
    polygon.rotation.y = Math.PI;

To me. It usually comes from experience .Or try several more times by controlling the controls provided by Babylon.js

1 Like

Sure I’ll explore Gizmo and Inspector more,
Thanks again :pray: