When I try to change the scale of an object to something random, instead it sets the values to 0,0,0, also this is ina prefab, and I think it is the problem, but I don’t know what to change about the script, as I am fairly new to unity, and don’t understand most technical terms yet, here is the code:
public Rigidbody rb;
public Material material1;
public Material material2;
public Material material3;
public Material material4;
public GameObject thisplanet;
int materialselect;
Vector3 planetsize;
// Start is called before the first frame update
void Start()
{
int materialselect = Random.Range(1, 4);
var randnum = Random.Range(3000f, 6000f);
Vector3 planetsize = new Vector3(randnum, randnum, randnum);
}
void Update()
{
if (materialselect == 1)
{
thisplanet.GetComponent<Renderer>().material = material1;
}
else if (materialselect == 2)
{
thisplanet.GetComponent<Renderer>().material = material2;
}
else if (materialselect == 3)
{
thisplanet.GetComponent<Renderer>().material = material3;
}
else
{
thisplanet.GetComponent<Renderer>().material = material4;
}
thisplanet.transform.localScale = planetsize;
}