2
$\begingroup$

I want to have my camera moves by "Follow Path", it moves pretty well except that its view angle is not what I want.

I want to have the camera's look-at point always to be the next point it moves to. How can I get this work with python script? (or is there a setting for that)

My guess is that if I set the rotation angle correctly at the beginning it will fulfill my requirement.

pi = 3.1415926
scene.camera.rotation_mode = 'XYZ'
scene.camera.rotation_euler[0] = rx*(pi/180.0)
scene.camera.rotation_euler[1] = ry*(pi/180.0)
scene.camera.rotation_euler[2] = rz*(pi/180.0)

where rx,ry,rz are the euler angle that I need to calculate at the beginning.

Thanks in advance

$\endgroup$
  • 2
    $\begingroup$ if you are using the Follow Path constraint check "follow curve" option and set "forward" to Z and "UP" to Y $\endgroup$ – Chebhou Apr 22 '15 at 1:22
  • $\begingroup$ are you doing the "follow path" using a script not a constraint ? $\endgroup$ – Chebhou Apr 23 '15 at 2:17
  • $\begingroup$ @Chebhou yes. I used "follow path" in the script. How can I set constraint? Thanks! $\endgroup$ – diodeBucks Apr 24 '15 at 17:55
1
$\begingroup$

You can access and alter the properties of the constraints of an object, all constraints are listed in object.constraints, access each constraint by its name or type and of course the index

cam = scene.camera
# if you are sure the constraint exist and has the default name
fol_path = cam.constraints['Follow Path']

fol_path.forward_axis = 'TRACK_NEGATIVE_Z'
fol_path.up_axis = 'UP_Y'

# to avoid errors in case it doesn't exist or has another name
for cons in cam.constraints :
    if cons.type == 'FOLLOW_PATH':
        cons.forward_axis = 'TRACK_NEGATIVE_Z'
        cons.up_axis = 'UP_Y'
$\endgroup$
  • $\begingroup$ there is error with fol_path = cam.constraints['Follow Path'] : KeyError: 'bpy_prop_collection[key]: key "Follow Path" not found' $\endgroup$ – diodeBucks Apr 29 '15 at 14:39
  • $\begingroup$ because the camera doesn't have the follow path constraint you have to add a follow path constraint to the camera before trying to access it , also to avoid errors you can use the second part , if you still have problems comment back $\endgroup$ – Chebhou Apr 29 '15 at 21:36

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.