1
$\begingroup$

I want to save the location of a child object during the parent's animation. My code populates the list with the last read value and none of the other values. If I print the z location each iteration with the below I can see the correct value at each frame. I don't understand why the list doesn't save individual vectors.

print(f'Z_Loc: {obj.matrix_world.translation[2]}')

enter image description here

import bpy
obj = bpy.data.objects["Cube.001"]
start_frame =  20
translations = []

for frame in range(2):
    bpy.context.scene.frame_set(start_frame)
    translations.append(obj.matrix_world.translation)
    start_frame += 1

for num, ob in enumerate(translations):
    print(f'num: {num} matrix: {ob}')
$\endgroup$
3
1
$\begingroup$

This gave the result I wanted.

translations.append(bpy.data.objects[obj.name].matrix_world.translation.copy())
$\endgroup$
1
  • $\begingroup$ No need to re reference : translations.append(obj.matrix_world.translation.copy()) $\endgroup$
    – batFINGER
    Jul 29 at 6:09

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.