Expression for "every other frame"?

   27293   11   3
User Avatar
Member
12 posts
Joined: June 2012
Offline
I was fooling around and trying to get a FLIP fluid to emit every other frame, under the Creation Tab. The default value is 1, so the fluid emits from frame 1 and then stops. I also used $F, to have it emit every frame.

I'm just curious if there is an expression to tell it to emit every OTHER frame?
In the process of learning Houdini. 3DS Max Artist currently.
User Avatar
Member
383 posts
Joined: June 2010
Offline
Do you mean you want to emit on odd or even frames ?
This could easily be done with modulo expression ..
www.woogieworks.at
User Avatar
Member
12 posts
Joined: June 2012
Offline
Well, I suppose you could look at it that way yes, since every other frame will be either always odd or always even.

I tried using a ($F%2), but technically that would just give me a value or 1 or 0, and in the Creation Frame, that means it would read as emitting on frame 0 or 1, and once it's past that, it basically acts as if it was only emitting on frame 1. Make sense?

So I'm wondering if there's a way to get it to actually look at the frame, or every other frame, using a $F kind of expression?
In the process of learning Houdini. 3DS Max Artist currently.
User Avatar
Member
383 posts
Joined: June 2010
Offline
you can multiply the frame with the modulo expression this would result in 0,0,2,0,4,0,6,0,8,0 ..
www.woogieworks.at
User Avatar
Member
12 posts
Joined: June 2012
Offline
So simply ($F)%?

Or I probably don't even need the brackets… just $F%?

Will try - thanks!
In the process of learning Houdini. 3DS Max Artist currently.
User Avatar
Member
383 posts
Joined: June 2010
Offline
I thought more of ($F%2) * $F but for the exact syntax I would have to try too ..
the first term gives you 0,1,0,1,0,1 .. and the second 0,1,2,3,4,5, .. the you multiply them together ..
www.woogieworks.at
User Avatar
Member
12 posts
Joined: June 2012
Offline
This works perfectly - thanks dulo!

Guess I gotta start thinking in expression terms instead of just numbers 8)
In the process of learning Houdini. 3DS Max Artist currently.
User Avatar
Member
1 posts
Joined: Dec. 2013
Offline
here you are
if(($F % 5 == 0),$FF,0)
do it for fun d
User Avatar
Member
1 posts
Joined: May 2014
Offline
hi all, thanks for the replies.
i want to know another way to do it. Am workin with the seed for the scatter node. I want that the value stays as it is and adds every N frame. In this solution if(($F % 5 == 0),$FF,0), it returns to 0 and its not what i want.
Thanks…
User Avatar
Member
1743 posts
Joined: March 2012
Offline
Guennoun Djamel
Am workin with the seed for the scatter node. I want that the value stays as it is and adds every N frame.
floor($F/13)
This should give a value that is initially 0, and increases by 1 every 13 frames. The floor function [sidefx.com] rounds the input value down to the largest integer that is less than or equal to that value.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
1 posts
Joined: Jan. 2019
Offline
its been some years, but if i have: $F%12==0 , every 12 frames is going to shoot some particles, but how do i stop them from going indefinite, they follow a path, so at the end they just spawn at the same point until the very last frame, help
User Avatar
Member
132 posts
Joined: July 2007
Offline
You can write an expression (in Hscript or python) to control or limit creation.
For example, in the default hscript, using the if() function:
if($F<20, $F%5, 0)

Or in python (after you switch the language for the field and/or operator):
if frame()<20:
   return frame()%5*frame()

And don't forget you can right-click on the field name (not entry area) and select Edit Expression or ctrl/cmd + E in field to get a pop-up text editor.
  • Quick Links