Jump to content
GlennimusPrime

Create Point That Lasts Only One Frame, At Random Time Intervals [SOLVED]

Recommended Posts

Posted (edited)

Hello Houdini vex wizards!

I'm having a lot of difficulty trying to come up with a solution for this one myself.

As the title mentions, I'd like a single point to be created for just one frame and then disappear again - I would also like this to happen at random time intervals as the frame number increases.
For example the point will flash on for 1 frame, then maybe nothing for 10 frames, or nothing for 2 frames, then another point flash and so on.

I'm not very good with time related things in vex, but would love to learn more about random time stuff if anyone has any ideas?

Edited by GlennimusPrime

Share this post


Link to post
Share on other sites
Posted (edited)

You could use a switch sop with your point plugged into the first input and a null plugged into the second input.

Then an expression in the switch like:

rand($F)>0.1

Which will make the point appear on roughly one out of every 10 frames.

Edited by PixelNinja

Share this post


Link to post
Share on other sites

Alternatively you can also use this code in sop level. Use the parameters to specify the min/max frame intervals. 

 

image.png.2cb7eb93e44a0121eca16fa3eb18caf8.png

Share this post


Link to post
Share on other sites

Beautiful! This is exactly the sort of control I was after, thank you @Ziyad!

Thanks for your input too @PixelNinja, although this method does not keep the point active for just one frame at a time.

Share this post


Link to post
Share on other sites

A similar method if you want to add a chance parameter:

if ( @Frame >= chi("start") && @Frame <= chi("end") )
{
    if ( rand ( @Frame + ( ch("seed") + 3145.5672 ) * 5463.4573 ) < ch("chance") )
        addpoint ( 0, 0 );
}

image.thumb.png.544014bd5989bd3301d5cfedbce76be0.png

Share this post


Link to post
Share on other sites
11 hours ago, GlennimusPrime said:

Beautiful! This is exactly the sort of control I was after, thank you @Ziyad!

Thanks for your input too @PixelNinja, although this method does not keep the point active for just one frame at a time.

Apologies, the expression should have been greater than rather than less than. I edited the original response.

Note that this doesn't explicitly stop a point appearing on sequential frames, though that is unlikely for small chance values. A value of 0.1 means the point will appear on roughly 1 out of every 10 frames.

Just posting this for completeness as a simpler counterpoint to the vex approach.

 

 

image.png.bf07014e34cf4003b5cc7ac9f65b75c9.png

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×