How to make dynamic camera?

Godot Version

4.2.2

Question

i need to make the camera zoom decrease while the distance between the enemy and the player increases

I did something similar by using an if to check the distance between the player and the enemy.

i dont know if this will work but, first enable the smooth drag on the camera, then add this camera as a child of player, then when you need to focus on the enemy, try reparent the camera to enemy node, see if it will move automatically