The original scale of construct layout is 1.
So when you want to zoom it, you need to modify the scale. The bigger the value, the bigger zoom you get.
To dynamically zoom our layout, use the following formula for every tick :
LayoutScale = lerp(current_scale,desired_scale,required_time_to_zoom)
Say that I have two characters which can move on their own. To zoom the camera based on on their distance, add this event :
Run the layout, and you can see that the layout is zooming smoothly.
Just like I said before, we need to modify LayoutScale. You got it.
To get the correct scale, we need to divide WindowHeight (for landscape view) or WindowWidth (for portrait view) with player distance.
Window Size = 640x480
Current layout scale = 1
Current distance = 300
What is the scale if the distance is now 600?
Scale = 480/600 --> 0.8
NEXT THING TO DO
Limit the scalling to get more control.
For instance, do it only when character distance is longer than 300, and less than 700.
if you like this tutorial, please like my