# Access points along a bezier curve

I've got a tube, created from a bezier curve, similar to this example. I'd like to be able to move an object along this curve, as if it were a spline, in Unity. From Unity, I need access to each point in world space, so that I can adjust the object that moves along it programmatically (Animation will not work).

Is there a nice way to turn the various points along that curve into objects that I can then get the position of inside Unity, or do I have to manually add objects?

Thanks in advance for any hlep!

• You could convert a curve to mesh and add particle system. Adjusting settings, you can get desired objects e.g. at the locations where vertices of the curve are placed. I'm not sure these cubes really can describe all the needed points of the curve though. Sep 8, 2015 at 17:43
• What about a script that created an Empty where each point on the curve is? Would that work for what you need? You can hook the Empty's to the points as well to control their position if needed. Sep 8, 2015 at 18:13
• @ToddMcIntosh That would be perfect. Any idea how I go about accessing these points in order to use them in a script? Sep 8, 2015 at 18:15

Would it be practical to use the formula for a Bezier Curve (wikipedia article)? You can evaluate it for t varying from 0..1. One complication is that the distance between evaluated points will vary, so if you want constant speed you'll have to compensate by adjusting your time->t mapping. P0..P3 correspond to the points and handles of each segment of the bezier curve.

Here is a short python example of how to inspect the control points and handles of a bezier curve (in case you are unable to inspect them in the N-panel pop-out of the 3D view):

import bpy

def mission1(curve):
for spline in curve.splines:
for kp in spline.bezier_points:
print("%r"%[kp.handle_left, kp.co, kp.handle_right])
print("")

mission1(bpy.context.active_object.data)

• That would be great, but I still need a way to get the points from the curve before I can do any math to interpolate the vertices myself. Sep 8, 2015 at 18:14
• I have upgraded my answer with sample python. Sep 8, 2015 at 18:23

I've found an alternative to the accepted answer:

If you create a path/curve, then create an empty object, vertex, and parent that object to the path/curve, after selecting the empty object again and going de-selecting Speed under the frames, it will duplicate itself across the path. At that point, there will be a new empty object along each section of the path and it will import into Unity the same way.