Yep, you use a LERP-based camera (aka Linear Interpolation), just like I do. The trick is to introduce a middleman object, which I call the Target
. Then, make the Target
continually follow the player, and change your code to X( "Camera" ) + ( X( "Target" ) - X( "Camera" ) ) * 0.05
. So far, it will behave exactly the same way as before. But now, you can constrain the target how you like (eg. with the above-mentioned Marshals
). The camera will still LERP smoothly, but because it's now following the target - and not the player directly - you have more control over where it's allowed to go.
In the GIF below, notice how the blue square (my Camera
) smoothly follows the faint grey square (my Target
). The Target
follows the player, but only within allowable areas. The Camera
smoothly LERPs to the Target, and therefore remains within the allowable areas too.
I don't think the Window Control object is going to be relevant for this. It's more about stuff to do with the actual window that contains your game or application (eg. minimise, restore, resize window, set to always on top, etc.).