Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help needed: Access Netcode / NetworkTransnform by code

Discussion in 'Netcode for GameObjects' started by WallaceHS, Aug 27, 2022.

  1. WallaceHS

    WallaceHS

    Joined:
    Aug 7, 2021
    Posts:
    9
    Hello!

    I would like my server to be able to enable/disable syncing (position/rotation) according to some ingame events.

    I am able to access Netcode/NetworkTransnform via inspector, but I don't know how to do it ingame, by code.

    Could you help me, please?

    Thank you much!
     
  2. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    229
    using Unity.Netcode.Components;
    At the start of the file, then:
    put_object_here.GetComponent<NetworkTransform>().SyncPositionX = false;
    for example
     
    WallaceHS likes this.