Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Beginner stuck on Networked Transform

Discussion in 'Unity Transport' started by brummer, Oct 14, 2022.

  1. brummer

    brummer

    Joined:
    Jul 3, 2013
    Posts:
    28
    I'm doing the hello world tutorial p2.
    So far so good, but when i got to the networked transform part, it just doesn't seem to work.

    On the server window, i can see the prefab moving in a circle, but on the client it's just sitting where it spawned.
    I can't really tell what could go wrong, considering how few components there are in play.

    Here is a screenshot of my player prefab: upload_2022-10-14_17-11-37.png
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,618
    By part two are you referring to this?
    https://docs-multiplayer.unity3d.co...-an-object-to-spawn-for-each-connected-player

    Are you testing in a build, or using ParrelSync? If build, have you tried starting either the client or server from the editor, and launch the build for the server/client? Either way helps to see the Console output.
    Do you get two spawned player instances on both client and server?
    How are you moving the player instance?
    What is in the HelloWorldPlayer script? Why is it disabled (unchecked)? Could that be the issue?
     
  3. brummer

    brummer

    Joined:
    Jul 3, 2013
    Posts:
    28
    https://docs-multiplayer.unity3d.co..._two/index.html#introducing-network-transform

    This is the part i'm referencing.
    I'm not sure what ParrelSync is.

    I test by making a build, clicking starting "server", so that there is no player on the host, and then in another build i start as client, so that there is only one "player".

    I've tested before by making my own tweaks to the basic "Position" calculation introduced in the series and that worked on both server and client.

    Currently i only have the "NetworkTransformTest" script from the page enabled, so nothing should be interfering.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,618
    This is ParrelSync: https://github.com/VeriorPies/ParrelSync
    It allows you to clone your current project and open it in a second Unity Editor instance. That way you can test networking without having to make builds, and you get the console logs and can debug both instances separately as needed.

    Hard to say what is wrong here. Maybe take a step back, revert the changes from this part of the tutorial and start over. Or maybe test with host and client so you get two players, maybe one works but not the other.
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,130
    would need to see the movement script also.

    networktransform requires server to handle movement i think,
    ClientNetworkTransform allows you to move transform locally
     
  6. brummer

    brummer

    Joined:
    Jul 3, 2013
    Posts:
    28
    This is all the code is:
    Code (CSharp):
    1. using System;
    2. using Unity.Netcode;
    3. using UnityEngine;
    4.  
    5. public class NetworkTransformTest : NetworkBehaviour
    6. {
    7.     void Update()
    8.     {
    9.         if (IsServer)
    10.         {
    11.             float theta = Time.frameCount / 10.0f;
    12.             transform.position = new Vector3((float) Math.Cos(theta), 0.0f, (float) Math.Sin(theta));
    13.         }
    14.     }
    15. }

    It seems to be working right now. All i did was remove NetworkTransform and NetworkTransformTest and re-add them, Nothing else.
    This kind of makes me afraid of how "stable" the new system is.