1 particle per object?


#1

Hello everyone. I need a help about Particle flow. I created an army with crowd. They are horse archers. I want them to throw an arrow between x-y frames. But each soldier should throw one arrow. So i created a plane (named it arrowsource) and linked it to each soldier’s bow and setup the particle flow graph. But now between the birth frames (x-y) some soldiers throw 2-3 arrows in same time and some soldiers are throwing nothing. In this case i searched the whole google and couldnt find any tutorial about 1 particle per object script. Please can anyone help me about it?


#2

Something like this will create one particle per object (in this example called ‘Archer’
change it to the name of your objects
) at frame 0:

On channels used pCont do
(
	pCont.useTM = true
	pCont.UseAge = true
)

On init pCont do
(
	global Archers = $Archer* as array
)

On proceed pCont do
(
	t = pCont.getTimeStart() as float

	if t < 0 do 
	(
		NumParts = Archers.count
		for i = 1 to NumParts do
		(
			pCont.AddParticle()
			pCont.particleIndex = pCont.NumParticles() 
			pCont.particleAge = 0
			pCont.particleTM = Archers[i].transform
		)
	)
)
on release pCont do
(
)

Put it into a Birth Script Operator. You can then use a Spawn Test to create the arrow volleys.


#3

thank you very much:) its working with your help.But its starting from frame 0 and i want to make it start from frame 460.When i change the Emit start time 0 to 460 from birth script operator it doesnt work. also i didnt understand what did you mean with “You can then use a Spawn Test to create the arrow volleys.” its working without it.


#4

Change the line

if t < 0 do 

into

 if t == 460 do 

edit:meh
 no idea why my reply comes above your post.


#5

thank you for the trying
i did " if t == 460 do " but its not working :frowning: when i change the “<” to “>” the archers are throwing like machine gun :stuck_out_tongue:


#6

Time values in MAXScript are in frames, but converting a time value to Float converts it to TICKS, and 460 ticks is around two frames depending on the FPS settings.

In the time conversion line, change the code to

t = (pCont.getTimeStart()).frame as float

to get actual frame values you can compare to.


#7

I would use the script to create particles for each archer and link them to the archers (no shape operator!). I would then use a Spaw Test to create the arrows. That way I don’t have to change the script to amend the animation. (At least thats my thinking
haven’t tried it
)


#8

thank you very much its working now. WOAAH:scream:


#9

Yeeaah got it. Next time i will try with your way. there are around thousands of archers so i had to do it in this way but the script you sent worked very well. This was my first attempt with PF. I will send a test preview soon. Thank you guys.


#10

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.