PDA

View Full Version : 1 particle per object?


JuMa
05-20-2009, 01:53 PM
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?

Piflik
05-20-2009, 02:22 PM
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.

scrimski
05-20-2009, 04:17 PM
Change the lineif t < 0 do into if t == 460 do
edit:meh..... no idea why my reply comes above your post.

JuMa
05-20-2009, 04:18 PM
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.

JuMa
05-20-2009, 04:48 PM
thank you for the trying
i did " if t == 460 do " but its not working :( when i change the "<" to ">" the archers are throwing like machine gun :P

Bobo
05-20-2009, 05:47 PM
thank you for the trying
i did " if t == 460 do " but its not working :( when i change the "<" to ">" the archers are throwing like machine gun :P

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.

Piflik
05-20-2009, 08:25 PM
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...)

JuMa
05-21-2009, 12:40 AM
thank you very much its working now. WOAAH:scream:

JuMa
05-21-2009, 12:52 AM
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...)

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.

CGTalk Moderation
05-21-2009, 12:52 AM
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.