Was just trying to figure out how to make a flickering light in Blender, which could act as an influencing light source from a fire or lightning, etc. After browsing the interwebs for a while I found a post on reddit from 5 years ago( https://bit.ly/2lIy7RX ) that seems to provide a pretty good python solution to this haha. I will post it below. Credit goes to @merschemek on this one. Here it is..
import bpy import random def randf(lo, hi): return random.uniform(lo, hi) bpy.app.driver_namespace["randf"] = randf
Once you’ve run it, use “randf(0,1)” as your driver/in the input box for the value that you want to animate. You can replace the “0,1” with any values that you want the randomized range to be restricted to.
UPDATE: An alternative method to achieve the same or very similar result is by setting key frames on the value you want randomized within the time range that you want it to randomize throughout. You would then open the graph editor and with the object you want the value randomized on selected hit the “n” key(with your mouse cursor over the graph editor) to bring up the properties menus. Next go to the modifiers tab and add the noise modifier. Your values with vary here(the guy in the tutorial I watched(see below) had his strength at 7500), but I finished with mine at 80 in my test file. My scale was at 2 and my depth was at 10. I also restricted the frame range to the frames that I keyed the values on initially.
This method requires more setup and doesn’t give you as much control in terms of specifying a specific value range to stay within, but it also doesn’t rely on a python script and creating drivers which can be beneficial.
*I discovered this technique on “CG Masters” youtube channel in a video titled “Lightning Flashes Using Noise Modifiers in Blender”. You can watch it for yourself here - https://www.youtube.com/watch?v=RF0ttU2ZUBk