Unity: Spawning emitter in a specific body part [SOLVED]

What’s up everyone!
I was checking the forum before posting it but didn’t find any thing useful to solve my problem.

I have animated character and I’m making a VFX for it. now I’m trying to set the position of the emitter to follow the moving hand (or any other moving body part later).

My Approach:
Animating the emitter position in the animation tab to follow the hand (since the animation is staying the same in this manner) but what happens If I want variation of attacks with same starting charge effect…?

Hopefully my request is clear, if not please ask me for a better clarification.


So I have a very good answer from @Anton that the emitter should be attached to the bone.

Thanks a lot Anton! If any one has other approach I will be happy to hear about it.

If your FX as a part of your character, for example, fire around hands of Evil, you can attach your FX to a needed bone. In Unity3D bones are just gameobjects inside a prefab. It will be a part of your Hero prefab. You also can change visibility of that FX by animation.
But if you want to reuse your FX for other heroes you need some script for managing that.
Something like that:


using UnityEngine;
using System.Collections;
using System;

public class CreateFX_DestroyAfterDeactivate : MonoBehaviour
    [SerializeField] public GameObject prefab;
    private GameObject fx;

    void Start()
        var fx = Instantiate(prefab);
        fx.transform.localPosition = transform.position;
        fx.transform.localRotation = transform.rotation;
        fx.transform.localScale = transform.localScale;
        fx.transform.parent = transform;

    void OnDisable()

Add your hero prefab from a project.
Create new empty gameobject in a scene.
Attach it to a needed bone of your hero.
Add that script to your new gameobject.
Set link of your fx to “Prefab” field of the script.
Hide your gameobject.

If you unhide that gameobject in runtime, it will instanciate (create new copy) your fx and that fx will be attached to the bone. If you hide gameobject again, script will destroy your fx. You can change visibility of your gameobject by a key of animation or if you can’t change an animation for some reasons (for example, animation exported from fbx), you need use Animation Events, which can be added to your animation. Events can run custom script’s functions which can change visibility of your gameobject.

1 Like

So TThanks a lot for the explanation :slight_smile: !!!

One question about your script , what is “[serializefield]” ?

Welcome! Hope it helps you. =)
[serializefield] - it’s a marker which makes Unity save user’s data from that field. It’s redundant in that case because Unity serializes all public fields for classes inherited from Component, GameObject and etc. Sorry, you can delete that.

1 Like