Posted May 08, 2025 by Dee-Dee-R
#Unity #Camera Controller #RPG
Now that I'm able to create a new character, and visualize it in a scene, I need a camera to explore the world.
While playing Baldur's Gate 3, I was struck by how smooth the camera movement felt, especially during exploration and combat.
To be honest, I found the camera in Baldur's Gate 3 occasionally struggled during combat, particularly when characters and enemies were on different elevation levels. In vertical or multi-layered environments, it sometimes had trouble maintaining a clear and useful view.
Still, overall, the experience was solid, and there are definitely some ideas worth borrowing. In fact, I realized I could build a custom camera controller inspired by that approach.
In BG3, the WASD keys move the camera across the XZ plane in world coordinates, the middle mouse button rotates it around a focal axis normal to the XZ plane, and the scroll wheel controls zoom. What stood out to me was the zoom behaviour: instead of moving the camera in a straight line, it seems to follow a curved path, almost like a parabola. When this motion is combined with rotation, the camera appears to glide along a 3D surface that resembles a paraboloid of revolution.
That idea stuck with me. I started experimenting, and the result is my Paraboloid Camera Controller, a custom camera system inspired by that cinematic, orbital feel.
Here’s an overview of what was done:
The goal was to create a camera controller that constrains a camera onto a paraboloid surface defined by the equation:
y = (1 / a) * ((x - Cx)² + (z - Cz)²) + Cy
where C: (Cx, Cy, Cz) is the paraboloid center, a is a coefficient of convexity: the higher a is, the flatter is the paraboloid convexity.
This means that the camera's height is a function of its distance from the vertical axis passing through the center point. The shape gives a natural, curved trajectory for the camera to move along, perfect for scenes involving large open vistas or top-down exploration, like RPG or Strategy games.
Here are the highlights of the work I’ve done to bring this camera controller to life.
1/a) to control its flatness or steepness.InputAction system with custom binding support.Camera.main as the default.You can see the Paraboloid Camera Controller in action in the following short video:
If you believe all the math you studied in high school and university has no real-world use, here's an example that proves otherwise.
This camera controller is still in development and has never been used in a real game. I'll keep testing it and improving it based on my needs and maybe on day I'll make a proper package.
If you’re working on a game or project that could benefit from this controller, I’d love to hear about your experience or provide any help! Feedback and suggestions are always welcome.
Here you find the source code (at the time of writing): Assets/Scripts/Management/Scene/ParaboloidCameraController.cs
Stay tuned for future updates, and happy developing! Ciao!
DeeDeeR