我正在尝试创建一个脚本,该脚本从骨架获取骨骼并将其移动到数组中的坐标,其中数组的索引与当前帧对应。当它从while循环中取出时它可以工作。但是,由于某种原因,如果我把它放在while循环中它将无法工作。救命啊!
这是我的代码:
import bpy
from mathutils import Vector
array = [Vector((-0.001926896977238357, -0.004546209704130888, 1.658395528793335)), Vector((-0.49396175146102905, -1.6861768960952759, 0.02942873351275921)), Vector((-0.4931643009185791, -1.6861921548843384, 0.029441120103001595))] # shortened for ease of reading
armatures_obj = bpy.data.objects['Armature']
head_bone_new = armatures_obj.pose.bones['f_avg_Head']
for frame in range(1): # frame, co in enumerate(array):
bpy.data.scenes[0].frame_current = frame
co = bpy.data.objects['Empty'].location
head_loc = armatures_obj.matrix_world.inverted() * co
head_bone_new.matrix.translation = head_loc
head_bone_new.keyframe_insert('location',frame=frame)