Prefab connected to empty gameobject with scripts, empty moves, prefab doesnt?

Hey, So, I have a prefab with a particle effect, which is connected to an Empty game object with scripts.

The script is a "damage" script, which shouldn't matter, but the other script is a move script...

Looks like:

var speed = 1;
function Update () {

    var dir = Vector3.up;
    var relative = transform.TransformDirection(dir);
    transform.position += relative * -speed * Time.deltaTime;

    if(transform.childCount == 0)


What this does, is move the empty game object, but NOT the prefab that's a child to the empty game object...

Then, once the particle system runs out, it kills the empty gameobject too.

Problem is, the empty game object moves, but the child (The particle system prefab) does not..

So, question: How do you get it so that the child moves too?

Hey you need to set the transform of the prefab to the parent (empty) gameObject something like myPrefab.transform.parent = transform;

Your description is a bit confused:

In the Project view, you see a list of things. Pretty much everything listed here, except for folders is a "pre-fab" in a sense. The typical reference in Unity is to prefab GameObjects (indicated with the blue cube that has a piece of paper on the bottom-right).

In your Hierarchy view, the objects are instances. These instances may refer to the prefabs, but they are not the same thing. If you change a prefab, all linked instances that do not override the pre-fab will change. If you change an instance of a prefab, only that instance will change.

If I understand your situation, you should have a hierarchy like so:

Empty GameObject
    Particle System Prefab Instance

Empty GameObject has the posted script attached and moves.

Empty GameObject moves, but Particle System Prefab Instance does not? If this is the case, I can only assume that your hierarchy does not look like the above unless you've got some collisions or something getting in your way.

What boymeetsrobot was referring to was that in code, if you have instantiated your prefab as Particle System Prefab Instance, it will not be the child of Empty GameObject until you tell it to be with code like:

var prefabInstance : GameObject = Instantiate(prefab, transform.position,
prefabInstance.transform.parent = transform;