- Home /
              This question was 
             closed Nov 10, 2011 at 04:12 PM by 
             aldonaletto for the following reason: 
             
 
            Question already posted: http://answers.unity3d.com/questions/185021/issue-instantiating-prefab-in-c.html
 
               Question by 
               dan_viv · Nov 10, 2011 at 04:10 PM · 
                c#instantiateprefab  
              
 
              Issue Instantiating prefab in C#
HI There,
I'm trying to instantiate an object using C# to a specific spawn point. I want it to instantiate as a child of the script object as well..
My code so far is as follows:
 using UnityEngine;
using System.Collections;
public class enemySpawn : MonoBehaviour {
 public float spawnTimer;
 public float spawnGap;
 public GameObject parentGameObject; 
 public GameObject enemyObject;
 public Transform spawnA; 
 public Transform spawnB; 
 public Transform spawnC;     
 public Transform spawnD; 
     
     
 // Use this for initialization
 void Start () {
 spawnTimer = 0;
 spawnGap = 7.0f;
 }
 
 // Update is called once per frame
 void Update () {
     
     if (spawnTimer > 0)
         spawnTimer -= Time.deltaTime;
     
     if(spawnTimer < 0)
         spawnTimer = 0;
     
         if(spawnTimer == 0){
         spawnTimer = spawnGap;
         GameObject go;
         go=Instantiate(enemyObject,spawnA.position, spawnA.rotation) as GameObject;    
         go.transform.parent=transform;
         }
 
 }
}
This instantiates an object, but it's instantiating it with a messed up scale. Rather than the objects scale of 0.6, it's giving it '6.25e-05'
               Comment
              
 
               
               koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                