Wednesday, July 23, 2025

unity – Colour is altering in multiplayer with out specific syncing

In netcode for GameObject, community object script is used to make it networkable which suggests if the thing instantaited it’s going to seem on all shoppers. Community Remodel assist you to sync the remodel over the community. In order for you Sync different data both you could use NetworkVariable or Distant Process Name (RPC).
I’ve under script its change the color of the mesh when it hit with the collider. My query is that why the color is syncing? From host to consumer and consumer to host.

utilizing Unity.Netcode; utilizing UnityEngine;

public class CubeTrigger : MonoBehaviour {
    //NetworkVariable shade = new NetworkVariable(Colour.white);
    Colour shade = Colour.inexperienced;
    // Begin known as as soon as earlier than the primary execution of Replace after the MonoBehaviour is created
    void Begin()
    {
        
    }

    personal void OnTriggerEnter(Collider different)
    {
        Debug.Log("Set off" + different.identify, different.gameObject);
        //different.gameObject.GetComponent().materials.shade = shade.Worth;
        different.gameObject.GetComponent().materials.shade = shade;

    }

    personal void OnTriggerExit(Collider different)
    {
        Debug.Log("Exit Set off" + different.identify, different.gameObject);
        different.gameObject.GetComponent().materials.shade = Colour.blue;
    } }

I’m not explicity syncing. I can assume with out explict it solely occurs if it happen on the server. However why it’s taking place? Does it means every other factor that we aren’t doing will mechanically sync? or I missunderstood the entire idea.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles