script loop to frame 0 help


#1

HI

I have a particle system made from a Birth Grid.
After events and forces happen I want the particles to return to their exact grid position.
The Find Target By Script Vector should work I believe but my scripts and Data Operator scripts all fail.
Is it because Im not capturing the vectors at their initial position at frame 0?
Shouldnt this script below work?
Or am I not sending out a vector script correctly?
thanks for any help
very appreciated

remainz


on ChannelsUsed pCont do
(
pCont.usePosition = true
pCont.useVector = true
pCont.useTime = true
)

on Init pCont do ()

on Proceed pCont do
(
count = pCont.NumPArticles()

for i in 1 to count do
(
pCont.ParticleIndex = i
pCont.ParticleTime = 0
pCont.ParticleVector = pCont.ParticlePosition
)
)

on Release pCont do ()


#2

The script works but it seems to need to be passed out of the event with an Age Test of 0.
Then the forces can be applied with another event age test.
Then the Find Target attached to a stop and age test back to force event.


#3

You are constantly grabbing the position, you need a new in event check or some other if/then so that you only grab the initial position once.


#4

Thanks Johnny.
I have already been checking your vimeo vids to learn pflow.

I had tried to assign the script to just use frame 0 in both Script Operator and Data Operator but no luck yet.

Thereโ€™s so many options . Do I use particleAge or particleTime.
Neither works

on ChannelsUsed pCont do
(
pCont.usePosition = true
pCont.useVector = true
pCont.useTime = true
)

on Init pCont do ()

on Proceed pCont do
(
count = pCont.NumPArticles()
pCont.ParticleTime = 0

for i in 1 to count do
(
pCont.ParticleIndex = i

pCont.ParticleVector = pCont.ParticlePosition
)
)

on Release pCont do ()
on ChannelsUsed pCont do
(
pCont.usePosition = true
pCont.useVector = true
pCont.useAge = true
)

on Init pCont do ()

on Proceed pCont do
(
count = pCont.NumPArticles()
if pCont.ParticleAge == 0 then (

for i in 1 to count do
(
pCont.ParticleIndex = i

pCont.ParticleVector = pCont.ParticlePosition
)
)
)

on Release pCont do ()

#5

So there are two ways to capture what you need. The fastest/easiest is to use Box#3/ADM to write to the Script Vector it would look like this:

The scripted version would look like this: (note the if/then statement using pCont.particleNew)


 on ChannelsUsed pCont do
 (
 	 pCont.usePosition = true
 	 pCont.useVector = true
 )
 
 on Init pCont do 
 (
  
 )
 
 on Proceed pCont do 
 (
 	count = pCont.NumParticles()
 
 	for i in 1 to count do
 	(
 		pCont.particleIndex = i
 		if pCont.particleNew == true then
 		(
 				pCont.particleVector = pCont.particlePosition
 		)
 	)
 )
 
 on Release pCont do 
 (
  
 )
 

#6

You make it look so easy. :applause: :beer:

thanks a lot


#7

Thanks, I had a good teacher @Bobo :slight_smile: