I have a ramp with an incline that is controlled by a slider. On top of the ramp, I hope to be able to add different objects that will always sit on top of the ramp regardless of the incline.
I am using
getBoundingInfo().boundingBox.maximumWorld.y to get the objects to change position with the ramp but they are above the ramp. I am sure there is a better way of doing this.
Any help well be appreciated!
Can you set the sphere as a child of the ramp so that the rotation of the ramp also affects the sphere?
If @bghgary’s suggestion doesn’t suit you, you can try ray cast to find the mesh starting point on the ramp based on the x, z initial position of your mesh.
Here is an example :
(in replacement of my first ugly attempt https://playground.babylonjs.com/#W4JWZD#2)
Thank you @bghgary and @LeJohn for your help! @LeJohn’s solution with ray casting is perfect and helps with some other things I want to play around with.