Yeah, you could...
You could do this with trigonometry. You'd need three drivers: X Location, Y Location, and Z Rotation.
If you want to drive it based on, e.g., the frame, you could pick some constant T
for the period (the number of frames for a full circle) and r
for the radius, to get:
- X Location:
r * cos(frame / T * (2 * pi))
- Y Location:
r * sin(frame / T * (2 * pi))
- Z Rotation:
atan2(y, x) + pi/2
- Create a variable
y
with settings Transform Channel, Camera, Y Location.
- Create a variable
x
with settings Transform Channel, Camera, X Location.
...however, this is downright silly.
There is no reason you would really want to do this. Here are a couple problems:
- There's no need to be dipping into Python and drivers when all you want to do is a simple orbit.
- It makes things more complicated and more difficult to maintain. If you want to change the radius, for example, you have to change it in two locations. Same for the period.
- You have to have a trusted blendfile. Since Blender 2.68 you have to load a blendfile as "trusted" to use any Python (as you should!).
Better way to do this:
Use an empty, rotation, and a constraint. Create an empty and parent it to the object you want the camera to follow. Then, parent the camera to the empty. All you need to do now is insert keyframes on the Z rotation of the empty to rotate the camera around. To ensure that the camera faces it, add a Track To constraint.
How and why does this work?
When you rotate the empty, it also rotates all its children about the empty. This is exactly what you want — an orbit. The camera will turn, as well, but the Track To constraint makes sure it's in sync with the object. Otherwise, it could be turning at the right speed but always facing out, or always to the right, etc.
Benefits of this solution
- If you animate the object that the empty is parented to, the camera will continue moving correctly.
- This is really easy to do and takes about 30 seconds.
- If you work on a team, people will know exactly what you're trying to do.
- You can also animate the camera if you want (move it up or down, in or out, etc.) and the tracking will still work.
Here's what it looks like: