I made this script and looked all over the internet and tried everything I saw but I always get a error even tho I know I set it up properly but yet I still get a error. Atm I am using this set up and getting this error. If you could answer in code and not a link I well like that a lot better.
read this before you assume its just fixing a error.
error
Assets/Scripts/SpawnShips.cs(33,44): error CS0266: Cannot implicitly convert type `UnityEngine.Object' to `UnityEngine.GameObject'. An explicit conversion exists (are you missing a cast?)
here's the script
using UnityEngine;
using System.Collections;
public class SpawnShips : MonoBehaviour {
public string Help = "How many ships, type of ship, time befor start (keep it .5s or 1s";
public Transform[] spawns;
public GameObject[] SpaceShips;
public Vector3[] positionArray = new [] { new Vector3(0f,0f,0f), new Vector3(1f,5f,5f) };
private int currentPos = 0;
private float time = 0;
void Start ()
{
InvokeRepeating("spawn", 0, 0.5f);
}
void spawn()
{
int ships = Mathf.RoundToInt(positionArray[currentPos].x);
int TypeOfShip = Mathf.RoundToInt(positionArray[currentPos].y);
int TimeBeforStat = Mathf.RoundToInt(positionArray[currentPos].z);
time += 0.5f;
if(time == TimeBeforStat)
{
for(int i = 0; i < ships; i++)
{
GameObject h;
h = SpaceShips[TypeOfShip];
GameObject instantiated = Instantiate(h.transform); //instantiate the object
instantiated.transform.parent = spawns*.transform;//assuming this script is attatched to the desired parent*
-
instantiated.transform.localPosition = Vector3.zero;*
-
}*
-
} *
- }*
}