abuot AudioSource.Instantiate

partial code as following:


GameObject soundNewGameObject = new GameObject();

soundNewGameObject = AudioSource.Instantiate( this.gameObject.audio ,
playPosition , Quaternion.identity ) as GameObject;


but [soundNewGameObject] is null …

how can I use this function"AudioSource.Instantiate" to return to a GameObject???
because I want to control this parameters

soundNewGameObject is already instanciated as a GameObject when you do new GameObject(). That mean an empty game object will appear in your scene at that line. Now, i’m not sure what you’re trying to achieve with the second line, but I suppose you’re trying to add an audio component, which would be soundNewGameObject.AddComponent(AudioSource);

Keep in mind that Instantiate is used to create an instance of a prefab.