The following Script gives me this error:Cannot implicitly convert type UnityEngine.Object' to
UnityEngine.GameObject’. An explicit conversion exists (are you missing a cast?)
Script:
using UnityEngine;
using System.Collections;
public class spawningG : MonoBehaviour {
// Use this for initialization
public GameObject Baby;
public GameObject pdisplay;
public float myTimer = 1.0f;
void Start () {
pdisplay=GameObject.FindGameObjectWithTag("MainCamera");
line with errror--> Baby= Resources.Load("Cube1", typeof(GameObject));
}
// Update is called once per frame
void Update () {
if(myTimer > 0){
myTimer -= Time.deltaTime;
}
if(myTimer <= 0){
GameObject b= (GameObject)Instantiate(Baby,transform.position,transform.rotation);
b.GetComponent<HumanAI>().SetStats(Random.Range(pdisplay.GetComponent<Pointdisplay>().maxstaerke-10,pdisplay.GetComponent<Pointdisplay>().maxstaerke+10));
Debug.Log (b.GetComponent<HumanAI>().Stärke);
myTimer = Random.Range(5, 10);
}
}
}