Hi, I´m trying to network each player color based on the spheres network example. So each of my player´s controller (which already have a reference to its SyncedTransform and a PlayerState) have a reference to a Renderer which is a Skinned Mesh Renderer. In local all works fine but when other players spawn, their material don´t show in my local player.
This is the code for the material, hope that youre doing fine and you could help me 🙂
@serializable(Renderer)
mainBodyRenderer?:Renderer;
...
start(): void {
...
const isLocal = this.isLocalPlayer();
if(isLocal){
//If the instance of the object is Local then -> Request all of that instance
this.gameObject.getComponent(SyncedTransform)?.requestOwnership();
this.animator?.setBool("move",true);
try {
let index = this.userProfileInfo!.Avatar_color as number;
const mat = this.mainBodyRenderer!.sharedMaterial as MeshStandardMaterial;
if(mat){
const coloredMat = new MeshStandardMaterial();
coloredMat.copy(mat);
coloredMat.color = this._avatarSettings!.avatarColors![index];
this.mainBodyRenderer!.sharedMaterial = coloredMat;
}
} catch (error) {
console.log("No user info found");
}
}
...
isLocalPlayer(): boolean{
const isConnected = this.context.connection.isInRoom;
return !this.playerState || !isConnected || this.playerState.isLocalPlayer;
}