24
$\begingroup$

I have an object at a fixed position in 3D space. I would like the camera to circle around it while facing it. I want to path of the camera to be circular in 2D, meaning that it does not move up or down.

I need this to be pretty accurate. I don't want to manually set a keyframe every frame for position and rotation. I would like to do this maybe with an expression, not with manual keyframing. I am not sure how to go about this but I think it is going to involve Python as well as some trigonometry.

$\endgroup$
  • $\begingroup$ No keyframes on the camera or no keyframes at all? $\endgroup$ – wchargin Oct 23 '13 at 0:55
  • 4
    $\begingroup$ The requirement of not using a keyframe, is strange (and unnecessary I think). Rather then add odd limitations to your questions - can you give more details about what your looking for? - or just state why you can't use keyframes is fine too. $\endgroup$ – ideasman42 Oct 23 '13 at 4:46
  • $\begingroup$ I meant no manual keyframes. A start and end key is fine but not for every frame. $\endgroup$ – Vader Oct 23 '13 at 12:46
47
$\begingroup$

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.

Constraint and parent method

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:

Rotation demonstration

$\endgroup$
  • 1
    $\begingroup$ well if its so silly, what is the proper way of doing it? $\endgroup$ – Vader Oct 23 '13 at 1:07
  • 1
    $\begingroup$ @Jebediah see my edit. $\endgroup$ – wchargin Oct 23 '13 at 1:10
  • $\begingroup$ will the path be circular though? $\endgroup$ – Vader Oct 23 '13 at 1:11
  • $\begingroup$ @Jebediah yes, it will. $\endgroup$ – wchargin Oct 23 '13 at 1:14
  • 3
    $\begingroup$ @Jebediah it's not; that's just me manually rotating with my mouse (as you can see by the rotation cursor). If you inserted keyframes on the Z-rotation of the empty instead you would get constant (or linear, or Bézier, or whatever you want; it's a normal keyframe now) velocity. $\endgroup$ – wchargin Oct 23 '13 at 1:41
15
$\begingroup$

Another option would be to use a Curve Circle. Set the center point of the circle to the center of the object you want to orbit around. Parent the camera to the Curve Circle using the Folow Path option. This gives you a perfect, scalable circle but also allows you alter the shape of the orbit if you want by manipulating the points on the circle.

$\endgroup$
  • $\begingroup$ A good addition to this answer would be some screen grabs to show setup of constraint as setting the Up axis can be confusing $\endgroup$ – 3pointedit Oct 13 '16 at 11:02
  • $\begingroup$ You can check how to use it there : youtube.com/watch?v=SqOso5jgYa4 $\endgroup$ – Ivan Gabriele Dec 11 '16 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.