I have a script that creates a closed curve, and I now want to have a camera which moves along the curve and looks slightly ahead on the curve. The camera moves, but it doesn't stay on the curve itself. (I also haven't tried to tackle the looking ahead).

import bpy

points = [((-10.875,-0.444,0.122),(-16.375,5.056,0.122),(-5.375,-5.944,0.122)),

curveData = bpy.data.curves.new('path', type='CURVE')
curveData.dimensions = '3D'
curveData.resolution_u = 2

polyline = curveData.splines.new('BEZIER')
polyline.use_cyclic_u = True
for i, ((x,y,z), (lh_x, lh_y, lh_z), (rh_x, rh_y, rh_z)) in enumerate(points):
    polyline.bezier_points[i].co = (x, y, z)
    polyline.bezier_points[i].handle_left = (lh_x, lh_y, lh_z,)
    polyline.bezier_points[i].handle_right = (rh_x, rh_y, rh_z)

curveOB = bpy.data.objects.new('path', curveData)

scn = bpy.context.scene
scn.objects.active = curveOB
curveOB.select = True

cam = bpy.data.cameras.new("Cam")
cam_ob = bpy.data.objects.new("Cam", cam)

cam_ob.location = points[0][0]

cam_ob.select = True

The camera is following the curve, it is just offset right now so the behaviour looks odd.

You need to set your camera to the starting point of the curve. Which is the point (-0.284,16.306,0.122).

| improve this answer | |

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.