I am using a main camera to zoom into my gameObject using the scroll wheel. I’ve got the script working, but when I play, the main camera x and y values snap to 0 instead of staying where they are located in space. I need it a little off center for my GUI panel. How do I keep the camera position values at x = 0.28, y = -0.2 while I zoom?
The problem is, that you assign a zdistance vector, which by default have x and y set to 0. You have to use actual x and y from localPosition, by reading current local position, modifying z value, and then assigining it back: