hey, i am trying to make a script where when the object get´s clicked on it´s color changes, that works, also networking is working, the actual problem is, when a player joins after the object´s color has changed, then the color displayed to the late joined client is as it had never been changed, how can i update the variable? what am i doing wrong?
if i had to guess i´d say the problem is at UpdateColor() what script would send a variable to the clients?
var changed : boolean;
function OnMouseDown () {
networkView.RPC("colorBlack" , RPCMode.All);
}
//send over information
@RPC
function colorBlack () {
if(changed == false){
changed = !changed;
renderer.material.color = Color.black;
}else{
changed = !changed;
renderer.material.color = Color.white;
}
}
function OnPlayerConnected (){
if(networkView.isServer)
networkView.RPC("UpdateColor", RPCMode.Others);
}
@RPC
function UpdateColor(){
changed = changed;
}
what is your age lol, im 14
try this
RPCMode.AllBuffered
try these then
RPCMode.Others
RPCMode.OthersAll
RPCMode.Server
I dont understand why AllBuffered wont work? did u declare that in both @RPC and the networkView
i declared them at the networkView
at the @RPC how would i declare it? using this?
function colorBlack (RPCMode.AllBuffered) {
Problem persists, but this time it´s with the spawning of players, if i spawn a new player, the old one does see that new player, but the new player does not see that old one, which means that, there is no current instantiation of the old player to the new player, is there any way i can keep track of the older players networkView and then just instantiate a new player at the old player´s position?
where to declare?
networkView.RPC();
thats where, hence you have 2 of those, you’ll have to change them both. Your cause then happens, when other players cant see eachother? im guessing you tried using Others and OtherBuffered, these two update the RPC call to others but not to itself.
The fix to instantiate of old prefabs can be solved using RPC calls that update the movement of players, just like u did, or by attaching a NetworkView component to the player, so it does the rest- but ill prefer by script rather than NetworkView component(u still needed though)
I my GameObjects are being instantiated by Network.Instantiate , and they have a networkView component, I found a simple way to "fix " the issue, i made the host to click a button whenever the game should start, which means that the players only get instantiated when everyone is ready, but that can´t be considered a fix, it just hides the problem…