I have this code Code (CSharp): using UnityEngine; using System.Collections; public class spawn : MonoBehaviour { public Transform[] spawnPoint; public GameObject tnt; public int Level = 1; public int a = 0; public int score = 0; public float offsetY = 40; public float sizeX = 100; public float sizeY = 40; public float delay; public Transform Count3; public Transform Count2; public Transform Count1; public Transform CountGo; public Transform CountSpawn; // Use this for initialization void Start () { Time.timeScale = 0; InvokeRepeating ("SpawnTNT", 4, delay); } void Update () { if (a > 10) { if(delay > 0.3F){ delay *= 0.9F; a=0; Level++; } } } void SpawnTNT () { int i = Random.Range (0, 5); Instantiate (tnt, spawnPoint [i].position, Quaternion.identity); a++; } void OnGUI() { GUI.Box (new Rect (Screen.width / 2 - sizeX/2, offsetY, sizeX, sizeY), "Score: "+score); } void addScore () { score++; } void Go () { Time.timeScale = 1; Invoke ("SpawnCount3", 0); } void SpawnCount3() { Instantiate (Count3, CountSpawn, Quaternion.identity); } } And im getting these errors Code (CSharp): Assets/scripts/spawn.cs(68,17): error CS1502: The best overloaded method match for `UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion)' has some invalid arguments Assets/scripts/spawn.cs(68,17): error CS1503: Argument `#2' cannot convert `UnityEngine.Transform' expression to type `UnityEngine.Vector3'
CountSpawn is a Transform, you need a position (Vector3). Code (csharp): Instantiate(Count3, CountSpawn.position, Quaternion.identity) Edit: This was misleading/incorrect, so struck out. Note, you're instantiating a transform there, is that what you want? (Count3 is a transform) did you want to instantiate a GameObject or a Transform? I expect you want a GameObject.
This page: http://docs.unity3d.com/ScriptReference/Object.Instantiate.html indicates that there are only two overloads to Instantiate, neither takes a transform.
I'm pretty sure that @LaneFox is correct. The two overloads both take Object, which I assume both Transform and GameObject both inherit from. From that link (emphasis mine): If you are cloning a GameObject then you can also optionally specify its position and rotation (these will default to Vector3.zero and Quaternion.identity respectively). If you are cloning a Component then the GameObject it is attached to will also be cloned, again with an optional position and rotation. As such, Transform is a Component (inherits from) and therefore it will clone the attached GameObject also (but I assume it still returns (correctly) a reference to the Transform and not the cloned GameObject, but the GameObject can be got from transform.gameObject, etc). I've amended my previous post to remove my misleading/incorrect statement.