Hello, Iām setting up the color of my avatar using the PlayerColor.ts as a reference. Currently Iām able to update the color of the avatar, but Iād like to ask how can I replicate the color that my user has selected to the rest of the users. Thanks in advance.
Hello @VicDev the PlayerColor scriptās purpose is to uniquely color each connected user with a stable color (based on their networking connection id).
Iām not how familiar you are with coding but you can network the selected color in a custom script if you need different behaviour:
But maybe it would be good to add that feature to the PlayerColor component
Thanks for your help. Iām an experienced c# dev, but a total noob with TS and JS. Iāve implemented the IModel interface on my class and Iām trying to send the gameobject this way: this.context.connection.send(this.connId, this.gameObject as IModel, SendQueue.Immediate);
uncaught range error: maximum call stack size exceeded
/node_modules/.vite/deps/chunk-BYWKJQSH.js?cf5a31f5:5110:14
at JSON.stringify ()
at Mesh.toJSON(https:192.168.3.8:3000/ā¦
Thanks for your response. Iāve created my AvatarColorUpdate type. Before sending the message, Iām converting my THREE.Color into a number with bit shifting. Now the error message is not being displayed anymore, but the color isnāt being updated over the network
const packedColor = ((col.r * 255) << 16) | ((col.g * 255) << 8) | (col.b * 255);
let myData = new AvatarColorUpdate(this.connId, packedColor);
Do you alos subscribe to the event? Insteads of āthis.connIdā you need to define a event key (e.g āchange-player-colorā) and then listen to the event to apply it (if(myData.guid === this.playerGuid) ...)
I wrote the code above on the onEnable method, and Iām sending my information when a button is clicked: ```Typescript
let myData = new AvatarColorUpdate(this.connId, packedColor);
console.log("send: ā+myData.connId+ā and "+myData.color);
this.context.connection.send(āavatarColorUpdateā, myData, SendQueue.Immediate);
the color of the avatar is being set up on the Quest browser and works fine there, but is not being replicated to the desktop browser. I can see myself moving the avatar (using quest controllers) on the desktop browser, but the color remains the same