I need to acsess the renderer of an object that I Instatiate() and It keeps saying that “renderer” is not a member of “Object”.enter code here
See the code below for the script. Thanks!
#pragma strict
var xpos : float;
var spawnpoint : Vector3;
var coin : GameObject;
var rotation : Quaternion;
rotation.eulerAngles = new Vector3(0, 0, 0);
var newCoin :Object;
function Start () {
InvokeRepeating("CreateCoin", 1, 1);
}
function Update () {
Destroy(GameObject.FindWithTag("Coin"),10);
}
function CreateCoin(){
xpos = Random.Range(-50.0,50.0);
spawnpoint = new Vector3(xpos, 80, 0);
var myColor : Color; // This is just working for another part of my script, Please Ignore.
var mode : boolean = Random.value > 0.5f;
var rand : float = Random.value;
var index : int = Random.Range( 0, 3 );
myColor[index] = rand;
myColor[( index + ( mode ? 1 : 2 ) ) % 3] = 1;
myColor[( index + ( mode ? 2 : 1 ) ) % 3] = 0;
newCoin = Instantiate(coin, spawnpoint, rotation);
//newCoin = newCoin as GameObject;
newCoin.renderer.material.color = myColor;
}