How to combine animation and praticle system effects?

Hello! I am just started learning unity, and have a question. For example, I have a knight character model with a sword hiting animation. And I have a slash particle system effect like this: Unity Asset Store - The Best Assets for Game Making
So the question is: how can i combine in unity editor this 2 gameobjects: knights hit animation and slash effect which must appears when knights hit animation plays?

If you place your particle effect in your Assets folder, you can place it into a Resources folder to grab it from script. You can then make a new folder called “Resources” (without quotes “”). Place that particle system into the Resources folder. Now, on your knight, create an empty gameobject (Under GameObject > Create Empty) and line up that empty gameobject with the location you want the whole particle system to occur. Now make the empty a child of the sword so it moves with it.

Now, do you want the whole ‘slash’ thing to go across the entire blade or just that little piece where you placed the empty? If you want it to go across the whole sword, you can change the Ellipsoid on your particle system. Now to make it appear.

In your script where you start the animation, use the following code:


GameObject.Instantiate(Resources.Load("[name of your effect in the Resources folder]"));

Now what you’ll also need to do is make sure the lifetime on your effect is also as long as the swing. If you have it fire in a “shot” instead of constantly, you’ll need to also destroy it so it doesn’t fire more shots after the others die off. To do this, you’ll need to modify the code above:

GameObject lightEffectThing = GameObject.Instantiate(Resources.Load("EffectName"));

Now you have that specific light effect at this moment stored so you can simply do this:

GameObject.Destroy (lightEffectThing, 1);

The 1 represents the time it will wait until it destroys, so you can make it 2, etc.

If you want it to be faster than 1 second (0.2 for example), make sure you have an ‘f’ after it so Unity knows it’s a float (0.2f for example). Otherwise, Unity will think it’s a ‘double’ (another type of variable).

If you’re lost anywhere, please tell me what you’re confused about and I’ll try to help!