Im working on a little side project and im adding the ability to fly. But i would like that camera to slow move back away from the character the longer i hold down the fly button.
Also… i would like it to stop at a certain distance away from my character and then slowely come closer until he is back to to ground position or the start camera position.
I suggest adding a float curve which will define the camera distance from player. As a minimum set the normal position of camera, as a maximum the maximum distance from character.
Next just count time that passed since pressing the jump button. (In each frame add delta to some variable).
After releasing button just substract delta time from variable.
The ground position is harder then I thought. It depends how exactly you would like it to work. You can raytrace directly down or try to get exactly landing position. When you will have the distance to ground, add minimal distance to it and compare with value returned from float curve and pick the lower one.