Tscript - random in custom range?

Hello, I wanted to create a random number, I used Tscript: rand($F) it was giving me a random number every frame, but I need to customize the range from 0-1 to “0.4 to 1.1”, how can I do it just using a Tscript string?

fit(rand($F),0,1,.4,1.1)

OMG thank you so much! :stuck_out_tongue:

Nice one Achim!
And for future knowledge seekers, here’s the Python variant:

tdu.remap(tdu.rand(absTime.frame), 0, 1,  0.4, 1.1)

I was curious about performance, interestingly enough in TD build 2018.23470 the Python line gets optimized internally so much that it turns out to be faster than Tscript!
On my machine the Python version has 0.010 ms avg cooktime, while the Tscript version takes 0.016 ms.

See for yourself:
random_remap_Tscript_vs_Python.tox (702 Bytes)

1 Like