Restricting Fly Camera

Hi guys,

I was wondering what the best approach for restricting a FlyByCamera to a bounded box.

From what I’ve seen, there’s two ways, restricting the camera to a bounded box by making it a physical node and implementing partial physics - or putting the getLocation() in an update loop under certain conditions

But I’m sure there’s a better, easier way: so, that in mind, what’s the best way?

Thanks guys.

You could use an app state that does the check.
you could use a BoundingBox look at the intersect methods in it, you should find how to cheaply check if your cam position is inside the bounding box.
I’m actually surprised we don’t have an intersect(Vector3f) method…
In the app state, keep the previous position, if the new position is outside the bounding box restore the previous one.
Also you have to make sure your app state is after the FlyByCameraAppState, but that should be the case if you just add your app state in the simpleInit.

thanks so much! fixed everything