Moving camera based on a building's height

Hello Everyone! I’ve recently made a game (my first game ever so I have very little experience)

My game is titled Stack It Up! You stack and balance different shaped blocks on a platform (I know it is not the most original) and u get a point for each block. I attached a screenshot and a link to the Playstore if u want to try it.

Play Store

The issue is that I made a big compromise with the camera movement. It moves up 70 pixels regardless of whether the tower height’s has increased or the size of the block dropped.

If you build up too quickly, you hit the block moving back and forth.

If you build too slowly, everything will be out of frame.

Does anybody know a way I can make the camera move up based on the tower’s height? Any advice would be appreciated!

IF you have some idea how to check tower height
Then store it in variable for example change number of global variable TowerHeight to TotalTowerHeight

And now in camera Y you would go with
Set to GlobalVariable(TowerHeight)-10

Where that -10 would be your original starting Y position of camera
And maybe instead of set to it should be Subtract GlobalVariable(TowerHeight)+10

Just to be clear higher negative number like from -15 going to -35 is going 20 pixels UP
while positive number is going down

I figured out a different way. I set up a static line that moves with the camera. Each time a block reaches it it instructs the camera to move to move up.

I actually used multiple lines to determine the size of the block and the camera will move based on that.

Thank you so much for your tips though!


Are you using an object or raycast. Just curious. I was thinking about both. I was also thinking about using a for each object or JavaScript to get the highest Bounding Box Top value with a timer. Neither way seemed perfect and I like to test concepts.