ok, I have a small script that randomly picks a location and instantiates an object there. but for some reason I’m getting this error -
Assets/SetRandomButton.cs(30,28): error CS0266: Cannot implicitly convert type UnityEngine.Object' to
UnityEngine.GameObject’. An explicit conversion exists (are you missing a cast?)
here is the script -
using UnityEngine;
using System.Collections;
public class SetRandomButton : MonoBehaviour
{
public Transform[] buttonLocation;
public static bool activeButton = true;
public GameObject cannonButton;
public static bool buttonPresent = false;
void Start()
{
//buttonPressed = false;
}
void Update()
{
if(activeButton == false)
{
NewButtonLocation();
}
}
void NewButtonLocation() // Choose a new button to make active
{
int newLocation = Random.Range(0,buttonLocation.Length); // Pick number between 1 - 4
GameObject NewButtonLocation = Instantiate(cannonButton, buttonLocation[newLocation].position, buttonLocation[newLocation].rotation);
buttonPresent = true;
}
}
any suggestions guys ???