I instantiate a game object
And gives him a color
But host-side look, the color does not change
Why is this?
public class NBID : NetworkBehaviour {
[SyncVar]public Vector3 syncpos;
[SyncVar]public Color mycol;
void Update () {
Move();
GetComponent<Renderer>().material.color=mycol;
}
void Move(){
if(isServer){
syncpos = transform.position;
}
if(!isServer){
transform.position = syncpos;
}
}
}
public class S4play : NetworkBehaviour {
public override void OnStartLocalPlayer () {
palycol=KPS.color;//'KPS.color' is a static color
}
void Update () {
ccol(mybody,palycol); // 'mybody' is I instantiate objects
}
[Client]
void ccol(GameObject obj,Color col){
Cmdcol(obj,col);
}
[Command]
void Cmdcol(GameObject obj,Color col){
obj.GetComponent<NBID>().mycol=col;
}
}