27.6 C
New York
Friday, July 25, 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 implies if the item instantaited it can seem on all purchasers. Community Rework help you sync the remodel over the community. In order for you Sync different info both you must use NetworkVariable or Distant Process Name (RPC).
I’ve beneath 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 shopper and shopper to host.

utilizing Unity.Netcode; utilizing UnityEngine;

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

    non-public void OnTriggerEnter(Collider different)
    {
        Debug.Log("Set off" + different.title, different.gameObject);
        //different.gameObject.GetComponent().materials.colour = colour.Worth;
        different.gameObject.GetComponent().materials.colour = colour;

    }

    non-public void OnTriggerExit(Collider different)
    {
        Debug.Log("Exit Set off" + different.title, different.gameObject);
        different.gameObject.GetComponent().materials.colour = 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 occurring? Does it means some other factor that we’re not doing will robotically sync? or I missunderstood the entire idea.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles