Camera Bounds in Complex Shape
I want to have a camera follow a player where the player remains at the center of the camera at all times unless the camera would be outside the designated camera bounds. If the camera bounds were in a clean rectangular space it would be simple to check if the desired camera position would be out of bounds, and update the actual position accordingly. I'm not sure how I would do this for a complex shape that could have angles or even curves.
If a player is up against an angled wall, i don't want the camera to clip outside of the bounds, but for the player to appear at the edge of the camera.
I thought about doing this with the physics engine itself, but this causes the camera to rapidly jiter as it tries to forcefully enter a space where a collision would be. Is this something I'd use the physics engine for? How can I check the closest position an object could be in given the collisions around it?
Answer by iamchairs · Apr 19, 2020 at 03:45 AM
I think I worked out a solution. I don't know if it's the best solution but it seems to work. What I'm doing now is, instead of setting the cameras position to my player, I am giving the camera a velocity in the direction of the desired position. This way the camera can bump into things naturally in the physics engine.