Using script operator to subtract 1 from custom float
#1
Hi.

I have a custom float named "Hits". When there is a collision I send the particle to a new event and add 1 using --- test action>Increment Float --- in a 'Send Out' operator. This part is all fine and works as it should.

However, I also want "Hits" to decrease if there's been no collisions for 20 frames. I have added a 'Time Test' operator which sends out to a new event every 20 frames, and i'd like "Hits" to decrease by 1. At this point i'm stuck. From reading the forums it appears that the only way to decrease a custom float is to use the 'Script' operator. I have little to no scripting experience so am unable to do this.

Is there a few lines of code i could insert into the script operator to decrease "Hits" by 1?

   

Thanks,
Andy
  Reply
#2
It's not entirely clear to me what you're trying to do, but to decrement a value by 1 with a Script operator, you'd do something like this:

Code:
tf.SetCustomFloat(sInx, "hits", tf.GetCustomFloat(sInx, "hits") - 1);

That would go in the for-loop that iterates over all event particles and retrieves their simulation index (you can see this loop in the example script that is created when you create a new Script operator).
  Reply


Forum Jump: