Notifications
Clear all

[Closed] Pflow — path follow script

Hello guys and girls,

I know that’s THE question

I trying to find a scripting way to make particles following a path (spline) without using
“speed by icon” operator.
Even, if i put multiple paths, the particles are able to choose the path they must follow.

Ok for this time, one path will be great

I think the particles don’t have to move to the path by now.
They, just, imitate the shape of the path from their starting position.
Like move the first knot to the start point of the particle and let the particle follow the path.

I have an idea to make it but i don’t know how to script it.

I think to use the “pathInterp” and the “lengthInterp” functions to place the particles.
After, i offset them with regard to their starting position.

But i don’t know what particle parameter use for that and how make the particle follow the path over the time.

Could you help me to realise this ?

Thank you a lot for your help.

34 Replies

Hello Guys and Girls,

I made a simple script.
My particles follow the spline other on it no offset available by now.

The script


  on ChannelsUsed pCont do
  (
  	 pCont.useTM = true
  	 pCont.useAge = true
  	 pCont.usePosition = true
  )
  
  on Init pCont do 
  (
  	
  )
  
  on Proceed pCont do 
  (
  	count = pCont.NumParticles()
  	
  	splPath = $line01
  	NumFrames = 100
  	
  	for i in 1 to count do
  	(
  		pCont.particleID = i
  		PathPartPos = (pCont.particleAge as float/ticksperframe)/NumFrames -- 192 ticks per frame
  		pCont.particlePosition = (lengthInterp splPath PathPartPos)
  		
  	)
  
  )
  
  on Release pCont do ()
  
  

Just create a pf source and a spline a put the script in the event.
There’s a bug in my script. If you pass the 100f bar the particles go in straight line
and the script effect disappeared.

I have a lot of things to do.
The particles must follow the spline with he speed of the speed operator.
And the most important. The particles must offset their position to follow the path shape
from their starting position.

Anybody has an idea to do that ?

Just one line solve the bug.


 on ChannelsUsed pCont do
 (
 	 pCont.useTM = true
 	 pCont.useAge = true
 	 pCont.usePosition = true
 )
 
 on Init pCont do 
 (
 	
 )
 
 on Proceed pCont do 
 (
 	count = pCont.NumParticles()
 	
 	splPath = $line01
 	NumFrames = 100
 	
 	for i in 1 to count do
 	(
 		pCont.particleID = i
 		PathPartPos = (pCont.particleAge as float/ticksperframe)/NumFrames -- 192 ticks per frame
 		
 		if PathPartPos <= 1.0 do pCont.particlePosition = (lengthInterp splPath PathPartPos)
 	)
 
 )
 
 on Release pCont do ()
 
 

I just put an if statement to avoid the script giving a path parameter higher than 1.0.
The particle go in straight line after leaving the path.
If you put a find target the particle follow the spline and when they leave it, they go in straight line to the target.

Someone has an idea to offset the particle from the spline to their start position ?

I made a success. The script works with a spline and even an animated spline
I made some tests and that very exciting.


  on ChannelsUsed pCont do
  (
  	 pCont.useTM = true
  	 pCont.useAge = true
  	 pCont.usePosition = true
  	 pCont.useVector = true
  )
  
  on Init pCont do ()
  
  on Proceed pCont do 
  (
  	count = pCont.NumParticles()
  	
  	splPath = $line01
  	KnotPnt = (getKnotPoint splPath 1 1)
  	NumFrames = 100
  	
  	for i in 1 to count do
  	(
  		pCont.particleID = i
  		PathPartPos = (pCont.particleAge as float/ticksperframe)/NumFrames
  		
  		 if pCont.particleNew do 
  		(
  			pCont.particleVector = (pCont.particlePosition - KnotPnt)
  		)--end if
  		
  		if PathPartPos <= 1.0 do pCont.particlePosition = (lengthInterp splPath PathPartPos) + pCont.particleVector
  	)--end for
  
  )--end proceed
  
  on Release pCont do ()
  

I think is a basic script. But it interesting to know doing it.

The Offset works well.
Now the next step is to improve the code to allow multiple paths for the particles

Let’s do it.
Anyone ?

Awesome approach! I like it. :buttrock:

I hope you don’t mind me linking it to a related thread at Orbaz.

Cheers!

2 Replies
(@bobo)
Joined: 11 months ago

Posts: 0

Glad someone came up with it approach (again). Good job!

I published two DVDs almost a year ago (The PFlow Script Show Part 1 and 2 – see my sig.) which had the same solution to the problem and even some more variations to it, but nobody seems to want to buy them in this economy. On the positive side, since no code was posted from those DVDs, at least nobody on CGTalk seems to have pirated them either which is the Good News

(@bebetelanuite)
Joined: 11 months ago

Posts: 0

Hello Galagast,

I never mind you for linking my script.
I thought this thread definetly didn’t interesting someone because i post it 4 month ago.
I see your great thread about “particles spline follow” at Obaz and if i saw it earlier i didn’t broke my head on the starting of my script ;-).

I had a job to do with a lot of particles to direct. The only way i have to make them go to the target in a wavy way, was to make a wavy pipe and emit them inside. They bounce on the shape and stay in the right way. But it didn’t work as i want. So i tried to write a script to doing it.

I red some thread about using the “speed by icon” (not yours unfortunately). But it don’t give me the right way to work.
So i write this script. The second step is to make it work with multiples paths and let the particles follow a percentage of each of them. Just to give more variation to them.

Thanks a lot for your interest

I bought #1 two weeks ago, #2 will follow when I get my next paycheck. Can’t see Bobo starving

Oh the possibilities, really interesting results, thanks for sharing

LOL, I bought and downloaded them when they first hit the shelf, sucks noone is buying them it is great material and tremendously helpful. I refer back to them quite often.
I have seen quite a few opportunities to post relevant code from them but it didn’t feel right so I suggested buying the material instead:shrug:

BebeteLANUITE I had to find a work around to this problem every time I came across this issue. I just read this thread today and it seems your script is finally doing the job. Great stuff and thanks!

Hello Bobo,

Thank you for your opinion about this script.
That’s a good news for me if you have writed a more efficient script than mine (it can’t be different, Bobo is the One ).
I looked for your DVD’s but unfortunately i didn’t have enough money to buy them (i want them all :p). So, i’ll find a way to buy them if there is the solution for my problem inside them.

Wow… thx very much for that script… i was looking how to make this for a loong time…

Page 1 / 4