Particle Attachment for AI

From The DarkMod Wiki
Revision as of 09:31, 10 June 2007 by Greebo (talk | contribs) (categorised)
Jump to navigationJump to search

Attaching Particles to an AI

This page covers attaching particle systems to specific bones on an animated model (such as an AI).

The particle will be attached to a bone, this gives you plenty of options as most AI have 20+ bones. The names of the bones can be found in the AI's md5 file which can be opened with notepad or wordpad. For example, pagan_female_mesh.md5mesh contains the bones for the Pagan female. The joint names are usually fairly obvious as the animators need to find that info easily. left_hand is obviously a bone in the left hand.

You'll need to create a particle effect using the Particle Editor, or you can use an existing particle effect. Once you have that you can add some info to your AI's def file.

There are probably 2 ways to go with the particle attachment:

  • constantly emitted particle
  • particle emitted at intervals.

Adding the following spawnarg to your AI will add a particle named steam_puff to the joint named smokestack.

"smokeParticleSystem1" "steam_puff-smokestack"

Alternatively you can add the particle named smokestack to the joint named smokestack by using this line

"smokeParticleSystem1" "smokestack"

The first option is probably best as you can reuse particles instead of making a new one to match the joint name. Either way you'll notice that the above lines contain smokeParticleSystem1. An AI can have multiple smokeParticleSystems attached, in which case just increase the number: smokeParticleSystem2, smokeParticleSystem3, etc. The Monster_Boss_Cyberdemon.def from standard Doom 3 has 9 of these; 2 are used for footsteps, the other seem to be permanently attached flame particles to his back and mouth.

Note: Even though the spawnargs are called smokeParticleSystem#, you don't have to use them just for smoke. They work with any particle effect.

OK, great you say. But I only want a steam puff coming from my steambot's smokestack everytime the top of the stack opens. (In this case the stack happens to open towards the end of each animation.)

If so you'll need to add a line to your AI's model def description, as in the example below. This can be found in the AI's .def file (in this case lantern_bot.def).

anim walk		 models/md5/chars/steambots/lant_bot_walk.md5anim
{
frame 12	footstep
frame 31	footstep
frame 31     triggerSmokeParticle smokestack
}

In the above example, all of the particle effects attached to the bone named "smokestack" will start from the beginning every time the "walk" animation is at frame 31.

Importing the model and animation into a 3d program are probably the easiest way to find a specific frame, but you can also get it right by trial/error guessing. Most animations are around 30 frames, look for cycles. A bipeds walk anim is usually 2 steps (ie left foot, right foot) so a dust cloud coming from his right foot would be somewhere around frame 25, if it's late or early you can adjust until you get it close enough.

The benefit of using this method instead of a timing script is that you can match the particles timing to an AI's action even if something happens in time to mess up the sync.

Another consideration is that particles seem to be emitted about the same size as the bone they are coming from. You may need to adjust parameters in the Particle Editor or the particles def file to resize, I have yet to test this.


This is probably to be deleted soon, need to test self starting particles

I believe nothing other than "smokeParticleSystem1" "smokestack" is needed, they seem to start on their own, but if you want to start them you need to use above instruct