Apologies if this question has been answered already, but I can't seem to get this thing working.
What I am trying to do is have a cube follow a curve interpolated out of coordinates. Manually this would be done selecting both curve and cube and selecting "follow path" constraint in the Ctrl + P menu.
I have have put together a short script, but when I run it, the curve has the cube as a child, and there is a follow curve constraint. But the cube is not centered on the curve, and pressing play will not do anything.
I believe that I might be missing something conceptual, but can't really figure out what that is.
import bpy # Clearing scene for item in bpy.data.objects: bpy.data.objects.remove(item) # Simulation Parameters coords = [[0,0,0],[0,5,0],[0,0,15],[15,0,15], [0,0,20]] bpy.ops.mesh.primitive_cube_add() # making curve crv = bpy.data.curves.new('crv', 'CURVE') crv.dimensions = '3D' # initialize spline spline = crv.splines.new(type='NURBS') # a spline for each point spline.points.add(len(coords)-1) # 1 point by default # assign the point coordinates to the spline points for p, new_co in zip(spline.points, coords): p.co = (new_co + [1.0]) # (add nurbs weight) # make a new object with the curve obj = bpy.data.objects.new('object_name', crv) bpy.context.scene.collection.objects.link(obj) obj.name = "Path" # Constraining Space craft to orbit cube = bpy.context.scene.objects['Cube'] #cube.parent = bpy.context.scene.objects['Path'] bpy.ops.object.parent_set(type='FOLLOW') cube.constraints.new('FOLLOW_PATH') #Constraining cubesat to follow the path cube.constraints['Follow Path'].target=bpy.data.objects['Path'] cube.constraints["Follow Path"].forward_axis = 'FORWARD_X' cube.constraints["Follow Path"].use_curve_follow = True ```