Jump to content

Trigger Random Point On Random Frame


Recommended Posts

I'm familiar enough with triggering a random point on every frame, but when it comes to triggering a point on a random frame (and only triggering it for one frame only) I'm having some difficulties.

I have a somewhat working example available here. I'm telling a random point to turn red for one frame only. But when it comes to randomly choosing when that happens I'm not quite understanding.
image.png.187d8aa8aff7049f731080b46935cc8b.png

This somewhat works, but when adjusting the minimum rand time, nothing triggers at all.
image.png.c777289eeea323728dec230da482aea7.png

int trigger = @Frame + fit01(rand($F), chi("min_rand_frame"), chi("max_rand_frame"));

if (@ptnum == trigger && @ptnum == $F)
{
    v@Cd = set(1,0,0);
}

I'm not locked at all to any of this vex, so any other solutions are gladly accepted!

Any ideas?

trigger_on_rand_frame_v01.hiplc

Link to comment
Share on other sites

Posted (edited)

delete your "trigger_on_rand_frame" node

create a new attribwrangle1

Run Over Detail

 

float seed = chf("seed");
int min_frame = chi("min_frame");
int max_frame = chi("max_frame");
int trigger_frame = int(fit01(rand(seed),min_frame,max_frame));
//prt("trigger_frame: ",trigger_frame);

if(@Frame != trigger_frame)
    return;

int red_point = int(fit01(rand(seed),0,npoints(0)));//you can change it
//prt("red_point: ",red_point);

setpointattrib(0,"Cd",red_point,{1,0,0});

 

only one frame and only one point red

Edited by forever_kk
  • Like 1
Link to comment
Share on other sites

On 5/29/2024 at 9:34 PM, forever_kk said:
float seed = chf("seed");
int min_frame = chi("min_frame");
int max_frame = chi("max_frame");
int trigger_frame = int(fit01(rand(seed),min_frame,max_frame));
prt("trigger_frame: ",trigger_frame);

if(@Frame != trigger_frame)
    return;

int red_point = int(fit01(rand(seed),0,npoints(0)));//you can change it
prt("red_point: ",red_point);

setpointattrib(0,"Cd",red_point,{1,0,0});

Hi @forever_kk Thanks for your attempt. I have never seen a detail wrangle used to manipulate points before. Unfortunately I get errors right off the bat. I think 'prt' first needs to be defined. I wasn't aware of any VEX that uses semicolons either. Is this Python?

 

 

On 5/30/2024 at 3:53 AM, hannes603 said:

here you have rand point on random frame only once. (wip)

Also thank you @hannes603 this is working for now, although I would love to explore options that might be able to get away with using a solver where possible.

  • Like 1
Link to comment
Share on other sites

2 hours ago, GlennimusPrime said:

Hi @forever_kk Thanks for your attempt. I have never seen a detail wrangle used to manipulate points before. Unfortunately I get errors right off the bat. I think 'prt' first needs to be defined. I wasn't aware of any VEX that uses semicolons either. Is this Python?

 

 

Also thank you @hannes603 this is working for now, although I would love to explore options that might be able to get away with using a solver where possible.

I'm very sorry, "prt" is my custom debugging function. You can delete it

Link to comment
Share on other sites

Thanks for your reply @forever_kk It's somewhat working now with those two prt lines removed, although I'm only getting one single point changing to red when playing down the timeline.

I probably didn't explain in my initial post very well, but I'd like random single points to change red, for one frame only, but as the timeline plays down, I'd like other random points to also turn red for one single frame.
These points turning red would happen between a random frame time. I hope that explains a little better.

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.

Guest
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...