Hi, I'm making a perlin noise based texture, and i wanted the texture to be the same for all clients. Now it only generates texture for the host and all clients are getting is a blank/white texture. Can someone help?
code:
private void Start()
{
map = GetComponent<Renderer>();
if (IsHost)
{
scale = UnityEngine.Random.Range(1, 9);
offsetX = UnityEngine.Random.Range(0, 100);
offsetY = UnityEngine.Random.Range(0, 100);
SendParamsClientRpc(scale, offsetX, offsetY);
genMap(scale, offsetX, offsetY);
}
}
void genMap(float scale, float offsetX, float offsetY)
{
Texture2D txt = new Texture2D(width, height);
//Perlin noise
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
Color color = calcColor(x, y, scale, offsetX, offsetY);
txt.SetPixel(x, y, color);
}
}
for (int i = 0; i < 125; i++)
{
darkPoints.Add(darkSpots[UnityEngine.Random.Range(0, darkSpots.Count)]);
}
darkSpots.Clear();
txt.Apply();
map.material.mainTexture = txt;
}
[ClientRpc]
private void SendParamsClientRpc(float scale, float offsetX, float offsetY)
{
genMap(scale, offsetX, offsetY);
}