Hi, I was setting up a simple force that will kick in when the particles start moving too fast. and I wanted to decrease that force based on the time passed. And then it hit me…how do I measure time passed since a condition was met? Basically I did this:
I think you might need to store the time when the particles started moving too fast as an attribute on the particle. Then the code would be easier. Just subtract current time from saved time to determine your slowdown.
Using Houdini Indie 20.0 Windows 11 64GB Ryzen 16 core. nVidia 3050RTX 8BG RAM.
Enivob I think you might need to store the time when the particles started moving too fast as an attribute on the particle. Then the code would be easier. Just subtract current time from saved time to determine your slowdown.
That's what I thought but how do I store the time?
If an attribute does not exist and you assign to it, it is create automatically. So if length is your condition to begin, mark time at that point.
I don't know, maybe something like this…
if (v_length > v_min && v_length<v_max)
{floatsuccess = 0;
floatsaved_time = getattrib(0,"point","time_start",@ptnum,success); // success is 0 if attribute does not exist.if (success == 0) {// Attribute does not exist, this is the first time, so let's create it.@time_start = @Time;
}else{// Our attribute already exists so we can review it and make decisions.elapsed_time = @Time - saved_timeif (elapsed_time > 0.5) {// Time to reduce velocity value.}else{// Waiting to put on the brakes.}}}else{// Other code}
Edited by Enivob - Oct. 13, 2016 23:45:12
Using Houdini Indie 20.0 Windows 11 64GB Ryzen 16 core. nVidia 3050RTX 8BG RAM.
Enivob If an attribute does not exist and you assign to it, it is create automatically. So if length is your condition to begin, mark time at that point.
I don't know, maybe something like this…
if (v_length > v_min && v_length<v_max)
{floatsuccess = 0;
floatsaved_time = getattrib(0,"point","time_start",@ptnum,success); // success is 0 if attribute does not exist.if (success == 0) {// Attribute does not exist, this is the first time, so let's create it.@time_start = @Time;
}else{// Our attribute already exists so we can review it and make decisions.elapsed_time = @Time - saved_timeif (elapsed_time > 0.5) {// Time to reduce velocity value.}else{// Waiting to put on the brakes.}}}else{// Other code}
Thank you anivob! I allways absolutely disregarded the success return from the point function . But here it is to the rescue. I also like the idea of recording the time within the condition. I think I may end-up creating my own attribute “active” and use it as a check box to replace the success value. That way I can continuously turn on and off the clock. Thank you for the help.
mmm… I don't seem to get this to work. I basically adapted your system to the following but the problem seems to be that in the moment I equate time_start to @Time. the time recorded is not the time in which the condition is met but actually the attribute @Time. Basically time is still counting after the status success changed.