I have started to do realtime animations using Erindales XinputReader, which I find super easy to use and great. For a while I just recorded my animations realtime as well, with Obs, but I would like to try some more heavy renderings using this technique.
ChatGpt helped me write the script bellow, but it kills the driver in the keyframing process. So I am not sure how to continue on this. Apparently, drivers are calculated after keyframes in Blender, so a problem is that the recorded value from the driver ends up being 0 for each frame, although I am manipulating the driver in realtime while trying to record keyframes. I also tried parenting an object to an empty controlled by xinput (xbox-controller) and just recording the childs position, but I just get the value 0 recorded for every keyframe.
Does anyone have a suggestion what I can try next? Maybe itās possible in geometry nodes?
Hereās the script:
import bpy
def record_driver(scene):
# Access the object by its name
obj = bpy.data.objects[āObjectNameā]
# Access the shape key using its name
shape_key = obj.data.shape_keys.key_blocks["ShapeKeyName"]
# Evaluate the driver to get the current value
driver_value = shape_key.driver_add("value").driver.evaluate()
# Apply the driver value to the shape key directly
shape_key.value = driver_value
# Insert a keyframe for the shape key value
shape_key.keyframe_insert(data_path="value")
Clear any existing frame change handlers to avoid duplicates
bpy.app.handlers.frame_change_post.clear()
Register the handler to run on frame change
bpy.app.handlers.frame_change_post.append(record_driver)