Friday, July 25, 2025
HomeGame Developmentunity - Coloration is altering in multiplayer with out specific syncing

unity – Coloration 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 article instantaited it can seem on all shoppers. Community Remodel can help you sync the remodel over the community. In order for you Sync different data both it is advisable to 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 shopper and shopper to host.

utilizing Unity.Netcode; utilizing UnityEngine;

public class CubeTrigger : MonoBehaviour {
    //NetworkVariable colour = new NetworkVariable(Coloration.white);
    Coloration colour = Coloration.inexperienced;
    // Begin is named 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.identify, 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.identify, different.gameObject);
        different.gameObject.GetComponent().materials.colour = Coloration.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 every other factor that we aren’t doing will robotically sync? or I missunderstood the entire idea.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments