0
$\begingroup$

I'm following this tutorial: https://www.youtube.com/watch?v=sfn1MJ3X-dg&list=PLbjn7kaP877u1sX4zl081V8jUeSHDY18G&index=6

And halfway through he shows an example of how to drive the y-rotation of an object via a driver with the script: bpy.context.scene.frame_currentthe scripted expression that is supposed to drive animation via the timeline

His object then rotates according as he scrubs through the timeline. This doesn't work for me.

He's using Blender 2.8 and I'm using Blender 2.81.

Did scripting change in 2.81?

I'm running 2.81 on a Mac

$\endgroup$
0
$\begingroup$

A simple way around this issue would be to add an input variable with the the scene's current frame, then referencing it in the expression.

Your final setup will look like this:

Current frame variable setup

The steps to set this up are as follows:

  • Add an input variable
  • Change the variable type to 'Single Property' (from the dropdown next to the variable name)
  • Change the 'ID' type to 'Scene' (from the dropdown in front of the 'Prop:' label)
  • Select your active scene from in the Scene ID property search menu (from default startup you'll only see one scene named 'Scene')
  • Type 'frame_current' into the 'Path' property
  • type 'var' (or whatever you've named your variable) into the expression field

Input Variables are the proper way to read from RNA properties when using Driver expressions. This way Blender knows to update the dependencies and ensure the driver functions properly.

$\endgroup$
  • 1
    $\begingroup$ Thank you, that works great! $\endgroup$ – Seth Style Jan 9 at 18:21
  • $\begingroup$ Can simply use frame as the expression, no need for the variable. frame is known to the driver namespace and is scene.frame_current. $\endgroup$ – batFINGER Jan 9 at 23:19

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.