VEX / Solver: run for N frames if condition is met

   877   1   0
User Avatar
Member
30 posts
Joined: 4月 2015
Offline
Hi Everyone.
Trying to solve this problem:

I have a bunch of primitives: ABCDEFGH...
On every new frame I want to have a random selection of these primitives to run a code for, N number of frames.
The selection will always have the same number of prims.

The code that I want to be executed:
Random primitives get assigned an attribute f@foo with value of 1 descdending to 0 for N frames.

Example:

Frame 1 Prims A, C, F (while @foo>0 @foo=@foo-1/N)
Frame 2 Prims B, H, E (while @foo>0 @foo=@foo-1/N)
...

Would appreciate any pointers. I can't get my head around it.

Thanks!
User Avatar
Member
8551 posts
Joined: 7月 2007
Online
sounds like you can easily do it without any solver just single Primitive Wrangle
- assuming each primitive already has i@foo value
- define for each prim what frame you want it to start decreasing i@start_frame (like prims A,C,F would have it's value 1, B,H,E 2, etc.)

then append Prim Wrangle:
int decrease_amount = clamp(floor(@Frame) - i@start_frame, 0, i@foo);
i@foo -= decrease_amount;

EDIT: this is a simple decrement by 1 from the i@start_frame, feel free to customize for your logic
Edited by tamte - 2022年6月25日 18:10:56
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links