Created
January 31, 2023 06:26
-
-
Save CGArtPython/bcd142fab809e243053330eba7f9c863 to your computer and use it in GitHub Desktop.
Add a Bezier circle curve and an empty, make the empty animate by following the circle curve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
last_frame = 90 | |
# set the lenght of the animation | |
bpy.context.scene.frame_end = last_frame | |
# add a Bezier circle curve into the scene | |
bpy.ops.curve.primitive_bezier_circle_add() | |
bezier_circle_obj = bpy.context.active_object | |
# set the number of frames it would take to traverse the curve | |
bezier_circle_obj.data.path_duration = last_frame | |
# add an empty into the scene | |
bpy.ops.object.empty_add() | |
empty_obj = bpy.context.active_object | |
# add the "follow path" constraint | |
bpy.ops.object.constraint_add(type="FOLLOW_PATH") | |
empty_obj.constraints["Follow Path"].target = bezier_circle_obj | |
bpy.ops.constraint.followpath_path_animate(constraint="Follow Path", owner="OBJECT") | |
empty_obj.constraints["Follow Path"].use_curve_follow = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment