Instantiate as a Child of the Parent

This is probably an easy question but I have tried all permutations I can think of and its not working.

I want to instantiate ‘poisonSmoke’ as a child of the game object being poisoned so the particle effect will follow the game object. But no matter what I try it wont parent it.

Any help would be appreciated.

Thanks

Instantiate (poisonSmoke, Vector3(transform.position.x,transform.position.y, transform.position.z) , Quaternion.identity);

poisonSmoke.transform.parent = gameObject.transform;

You need to get the thing that is created by Instantiate and set that one’s parent, at the moment you are setting the prefab’s parent!

  var myNewSmoke = Instantiate (poisonSmoke, Vector3(transform.position.x,transform.position.y, transform.position.z) , Quaternion.identity);

 myNewSmoke.transform.parent = gameObject.transform;

You can add it at the same time you Instantiate it by doing this:

Instantiate (poisonSmoke, transform);

I find this the cleanest way.

The up to date solution is hidden in the comments so I post it here as an answer:

Object Instantiate(Object original, Vector3 position, Quaternion rotation, Transform parent)

have a look at this on how to access children http://unity3d.com/support/documentation/ScriptReference/GameObject.Find.html