Boundaries for camera movement #1682
Labels
area: renderer
Concerns our graphics renderer
good first issue
Suitable for newcomers
hacktoberfest
For newcomers from Hacktoberfest event
improvement
Enhancement of an existing component
just do it
You can start working on this, there should be nothing left to discuss
lang: c++
Done in C++ code
Required Skills: C++
Difficulty: Medium
Currently, we let the camera move freely in the scene. This can result in the camera accidently moving away from the visible map terrain. It would be better if we could set the boundaries of the camera movement according to the current size of the map, so that the camera can't be moved outside of the play area. This should be implemented for the
CameraManager
and not for the camera class itself!Tasks:
float
type to theCameraManager
class. For testing purposes, you can hardcode these 4 positions at the start:12.25f
(min x axis coordinate)32.25f
(max x axis coordinate)12.25f
(max z axis corrdinate)-8.25f
(min z axis coordinate)std::clamp
for this purpose.Note that the position the camera is at is different from the position the camera looks at! When we want to set boundaries, we usually want to set boundaries based on what the camera can look at. However this also means that we have to convert look-at coordinates to is-at (camera position) first. You can check how the camera dies this by checking out the
Camera::look_at_scene(..)
method.Further Reading
CameraManager
codeThe text was updated successfully, but these errors were encountered: