Hi all. I have created four objects from a single prefab, which has the following script on it:
using UnityEngine;
using System.Collections;
public class Treescript : MonoBehaviour
{
public int amount;
public int randomWood ()
{
System.Random num = new System.Random();
int c = num.Next(1, 4);
return c;
}
// Use this for initialization
void Start()
{
int rand = randomWood();
if (rand == 1)
{
amount = 50;
}
else if (rand == 2)
{
amount = 100;
}
else if (rand == 3)
{
amount = 150;
}
print("Wood amount: " + amount);
}
// Update is called once per frame
void Update()
{
}
}
The problem i’m getting is that all four objects get the same randomly generated number every time (apart from some strange circumstance where one is different). How do i fix this? Cheers,