-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How does the client synchronize to the serve #2844
Comments
Changing ownership of the in-scene placed NetworkObject will resolve the issue. By default, an in-scene placed NetworkObject is owned by the host-server. With ClientNetworkTransform (a.k.a owner authoritative), whoever the owner is of the NetworkObject has the authority to move the object. Let me know if this resolves your issue? |
ClientNetworkTransform has been mounted on the object. I don't know why the client can't operate it. The project is a VR project that wants to realize that objects in the scene can grasp the real-time synchronous position of each client. These have been realized, that is, there is no way to grasp objects on the client side like they have been set. |
NetCodeWork.zip
|
Once I check Spawn With Observers, which I can't do on the client (move, scale, rotate), I see Position XYZ in the Inspector panel keeps getting assigned. |
@BensonMaZIHao Regarding the Netcode side of things, your primary issue was that you were never changing the ownership of the interactable objects and so the ClientNetworkTransform (owner authoritative) would only synchronize to the Host player. I reduced your scripts down to 2 scripts: PlayerLogic: All player oriented motion and selection happens here (you only want the player object to handle the ray casts). Anyway, I attached the updated project. Let me know if this resolves your issue and if it all makes sense? |
Thank you very, very much! I tested the Demo and it really saved my day. There is also a question about whether I can assign values to GlobalobjectidHash manually, because all objects in our main project are generated dynamically and there is only one parent node. It bothers me that it is only generated in the Editor. There's no other way to solve this. In our project these are all different nodes, and they are all dynamically generated. How should I hang on NetWorkObjecks, only parentNode is not dynamically generated?
|
With scenes you can just create one or more blank scenes (or scenes that contain a commonly shared set of in-scene GameObjects and components). You would then just load one of the blank scenes additively. You can load more than one instance of the same scene additively (i.e. the scenes are like a blank canvas but also are known by all clients). For dynamically generating network prefabs, you will need to provide me with the details of how you are breaking apart/configuring your dynamically generated network prefabs in order for me to provide you with a more focused solution. There are many ways to handle this, but which one is the correct one depends upon how you are constructing your dynamically generated instances. |
Taking AssetsBundle as an example, I planned to mount NetWorkObjects directly when I made AssetsBundle, and then print AssetsBundle and load it into the project through network. But I found that the GlobalobjectidHash of the AssetsBundle that came in was the same, but not the same when I edited the AssetsBundle. Our project is divided into editor and player. We plan to allow users to create objects by themselves (we will assign a unique ID to each object) to mark whether they can be synchronized during editing, and finally package them to the player side to dynamically add synchronization related Settings according to the mark. Obviously, the ID of NetworkObjects cannot be dynamically generated during runtime. There is no way to set this dynamically (I also understand why the ID is not generated at run time, so that each connected client uses the same ID to determine the object related information synchronization). If we have to hang on Networkobjecks components when editing, it is impossible for us to execute every project in UnityEditor, which is contrary to our project. I can't find relevant cases of Demo, is there any relevant cases or solutions for this? |
That would be correct. Depending upon the modifications made to the AssetBundle and/or the project that opened it, the GlobalObjectIdHash value could be updated/changed since the GlobalObjectId is the hash value of the GlobalObjectId.GetGlobalObjectIdSlow value returned. You might find this thread useful for what you are trying to do. It is a long thread, but towards the end (last several posts) a solution is presented. Really, what I was wanting to know the details on was what aspects (i.e. just properties, adding additional NetworkBehaviours, etc) of your network prefabs (in the AssetBundle) would users be allowed to modify? Exposing the ability to modify/add NetworkBehaviours changes the network prefab which will definitely change the GlobalObjectIdHash value. Read over the above thread provided and see if anything covered there helps you to resolve your issue, but I would recommend looking over your approach and determine if you could abstract away the need to update the network prefabs.
The thread provided above addresses the complexities of allowing users to create their own content using NGO directly. The high-level alternate approach reduces your users' content creation down to a given set of classes (you provide) and interfaces they can implement and can be assigned to change the behavior of existing network prefabs. The former provides a wider range of flexibility for your users, but greatly increases the complexity on your side. The later has a reduce range of flexibility, but is much less complex for you in the end. |
Many thanks! |
Hello guys, I am developing a project using LAN synchronization, I encountered a problem when I do it again, two player information synchronization I have done, but there are other objects in my scene also need to synchronize, for example, there is a ball in the scene, the ball can be caught in the hand or (client + server), (Client + server) Sync to client I found no problem, but in my client there is no way to move this ball it should be locked all the time in sync?
The object has a Network GameObject and ClientNetworkTransform attached to it.
I can't find the way, whether there is a solution my project is about to reach node.
netcode for gameobjects version :1.7.1
Unity version 2022.3.2
The text was updated successfully, but these errors were encountered: