2
$\begingroup$

I'd like to render an object only at Frame 20. The common approach seems to be set 3 keyframes at Frame 19, 20, and 21. It's not too bad, but I really wonder if I can just use the current frame number as driver input. If it is possible a single driver is enough to express "only render at Frame 20".

$\endgroup$
0
5
$\begingroup$

This is the little code you have to set on a driver on the Render icon to get the object rendered only at frame 20.

enter image description here

$\endgroup$
7
  • $\begingroup$ I assume that works because toggles are effectively boolean properties? $\endgroup$ Oct 4 at 17:43
  • $\begingroup$ Yes, every on-off button is boolean, where 0.0 is off and any other value is on. $\endgroup$ Oct 4 at 17:44
  • $\begingroup$ The only downside I see to this is that the object remains visible in the viewport but disappears in the render, which can confuse people debugging animation in render view, but you could apply the same driver to the viewport toggle, I suppose $\endgroup$ Oct 4 at 17:48
  • $\begingroup$ Yes, it's usual to copy and paste the same driver on both. $\endgroup$ Oct 4 at 17:49
  • $\begingroup$ While I was trying out my identical-answer-to-yours, I found 'Temporarily Hide in Viewport' is not keyable....I wonder if there's a getaround.. $\endgroup$ Oct 4 at 19:29
3
$\begingroup$

There are many ways to do this. One of the easiest is to use the frame number as an input to control transparency in a shader:

Using Frame number to control Alpha

Here, the purple value field is purple because it has a driver which I've created by typing #frame into the field. This is a short cut for using the frame number. Set the frame value you want the object to appear as the second value field. If you're using this in EEVEE set the Blend Mode of the material to Alpha Clip.

You could type #frame == 25 directly into the Alpha input and it would create this driver:

driver for #frame == 25

but then it's pretty obscure what's going on.

Driver expressions are explained in the manual. You need to be aware of certain caveats but they are basically any Python expression that the driver can decode.

$\endgroup$
2
$\begingroup$

you can add a custom property (i named mine "prop") and then add a driver on the camera icon of your object and insert this into your driver:

enter image description here

enter image description here

enter image description here

$\endgroup$
4
  • $\begingroup$ I didn't realize the expression in driver is literally python expression. Many thanks. $\endgroup$ Oct 4 at 17:12
  • 2
    $\begingroup$ Or you could use the much simpler frame == var $\endgroup$ Oct 4 at 17:23
  • $\begingroup$ @LaiYu-Hsuan Here is the Driver expression manual section $\endgroup$ Oct 4 at 17:26
  • 1
    $\begingroup$ Also, the expression above contradicts the driver manual recommendation that 'Drivers should access object data via Driver Variables, rather than direct references in the Python expression, in order for dependencies to be correctly tracked.' Your driver expression can lead to unexpected behavior. $\endgroup$ Oct 4 at 17:54

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.