I was wondering how exactly I would code my camera so that when C is pressed, the camera returns to an object no matter where that object is (i.e. a continuously moving object). I am trying to code a program where you can view how planets move relative to other celestial bodies, and sometimes you may lose a planet. Any help would be appreciated.
You can use the transform.LookAt() command to look at a position or another transform. The camera transform is particularly useful to aim this way. In order to regard your target from a reasonable distance away, you'll probably want to preserve some notion of how far back the camera should be given the field of view and size of the object involved. Also, you'll probably want to tween the regard point and the camera point smoothly over time so that there isn't an instantaneous jump/jerk when you press C, unless that's what you want.