Jump to content

Random Number At Start Frame


Recommended Posts


in carve Node (secondU parameter) inside forEach i added bellow code to get random animation for each curve. 

But problem is it gives random value between 35-50 only at first frame, if frame is greater than one thn it gives 5

so how to store first frame random value for rest of animation ??

from numpy import interp
import random

currentFrame = intFrame()

jitter = 5

if currentFrame == 1:
    jitter = random.uniform(35,50)

return(interp(currentFrame,[1,jitter], [0,1]))
Link to comment
Share on other sites

Storage is typically done by using a solver. But you might be able to simply reference the initial random value from outside the loop. Store a random number on the primitive attribute of each curve. I guess I'd have to see the network.

Edited by Atom
Link to comment
Share on other sites

I'm not sure I got your question right, but if you meant to animate the carving of curves based on a random end frames between 35 and 50, here's a possible answer.


The trick is that there's no storing of script variables in SOPs, the script is evaluated and that's all you get at the end of it so your jitter variable is reset every time. Instead I used the primitive number as a seed for the random value (so I get the same random value for each curve) and then you just interpolate based on the current frame.




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...