How to communicate a string value from master to all clients
Options
I'm habing some problems with a random seed of a procedural map generator in a multiplayer game.
Every time the master creates the room, a new random seed is generated. It works fine and always generates a different map.
Here's the problem: when the client enters the room, the client itself also creates a new seed. Server and client find themselves in the same room, they can see each other, kill each other and all the other stuff, but they see a different map!
I want the master to generate the random seed (which is a string) and send this string to anyone who joins the room.
here's the script for seed generation:
using UnityEngine;
using System.Collections;
using Photon.Pun;
using System;
namespace Com.Davidushan.KillerChess
{
public class ProceduralNumberGenerator
{
public static int currentPosition = 0;
public static string key= Convert.toString((new Random()).next(20000000,21000000),8); //base 8 random number
public static int GetNextNumber()
{
string currentNum = key.Substring(currentPosition++ % key.Length, 1);
return int.Parse(currentNum);
}
}
}
I use the variable Key in GetNextNumber(), which I call many many times from another script.
Is there a simple way to communicate that KEY value from the master (photonnetwork.ismasterclient) to all the clients, in order to let them create the exact same scenery?
Every time the master creates the room, a new random seed is generated. It works fine and always generates a different map.
Here's the problem: when the client enters the room, the client itself also creates a new seed. Server and client find themselves in the same room, they can see each other, kill each other and all the other stuff, but they see a different map!
I want the master to generate the random seed (which is a string) and send this string to anyone who joins the room.
here's the script for seed generation:
using UnityEngine;
using System.Collections;
using Photon.Pun;
using System;
namespace Com.Davidushan.KillerChess
{
public class ProceduralNumberGenerator
{
public static int currentPosition = 0;
public static string key= Convert.toString((new Random()).next(20000000,21000000),8); //base 8 random number
public static int GetNextNumber()
{
string currentNum = key.Substring(currentPosition++ % key.Length, 1);
return int.Parse(currentNum);
}
}
}
I use the variable Key in GetNextNumber(), which I call many many times from another script.
Is there a simple way to communicate that KEY value from the master (photonnetwork.ismasterclient) to all the clients, in order to let them create the exact same scenery?
0