Constrain camera vertical height

I’d like to prevent a camera from going under my heightmap. The heightmap doc page has a good example in Babylon.js Playground, but you can still pan under the heightmap with control + click.

In I tried adding something based on camera._position.y being lower than a certain value, and although I can see this is being triggered, the subsequent camera.y = 120 isn’t. I’ve also tried it with setPosition.

This cannot work:

camera.y is not a property :slight_smile:

You have to use setPosition:

Thanks! Any idea how to stop the jitter on (have changed 120 -> 20) if I try to move the angle quickly?

You can try to reduce the remaining inertia maybe:

1 Like

Great, thanks.