Random particle test


#1

Hi to all!!!
I need to select random particles and send them out to another operator…How this can be done?


#2

A Script Test operator that sends out random particles based on particleID?

on Proceed pCont do 
  (
  	randomNum = pcont.rand0X 50
  	count = pCont.NumParticles()
  	for i in 1 to count do
  	(
  		
  		--print randomNum
  		pCont.particleIndex = i
  		if pCont.particleID == randomNum then 
  		(
  			
  			pCont.particleTestStatus = true
  			pCont.particleTestTime = pCont.particleTime
  		)
  	)
  )

#3

Thanks! This is what I need!


#4

If you wish less particles to be tested true you can change the randomNum value

to something like:

randomNum = 3*pcont.rand0X 50

Just a note the number 50 is the upper limit of the random number, which is tied to the particles ID.


#5

I have problem with spawn (by travel) when I turn it on, the script random test gives only two particles and when I turn off spawn (by travel) it gives normal quantity of particles.


#6

Placement of the test is somewhat important, since you are transferring particles to a new event by ID or index you need to figure out how many particles you will have in total at the end of your timeline.

This number should be set to the upper limit of the randomNum value (ie replace the 50 with the the variable count so it takes whatever the total number of particles is). So since you are creating new particles all the time the script test needs to be somewhere other than the event that holds the spawn operator so it has more particle ID’s/index’s to work with.

You could try something like this:

Max9_TestByRndNum.zip

on Proceed pCont do 
   (
   	count = pCont.NumParticles()
   	randomNum = pcont.rand0X (count/10)
   	for i in 1 to count do
   	(
   		--print randomNum
   		pCont.particleIndex = i
   		if pCont.particleIndex == randomNum then 
   		(
   			pCont.particleTestStatus = true
   			pCont.particleTestTime = pCont.particleTime
   		)
   	)
   )


#7

Thank you very much!


#8

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.