Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.15k stars 435 forks source link

1.0.1 has broken/changed `In Local Space` NetworkTransform syncing . Objects are at wrong location/orientation #2161

Closed akoolenbourke closed 2 years ago

akoolenbourke commented 2 years ago

We had a hierarchy of NetworkTransforms for our game which consisted of the body of a vehicle, wheels and children of the wheels. All but the parent (NetworkObject) were syncing in local space. This was required because for our wheels, if we didn't sync in local space they would lag (And interpolate independently) to the body and look terrible.

Now, in 1.0.1 the wheels themselves and up in the completely wrong positions (20 metres above the where they should be). Rotation of the child body is out by 90 degrees and it will "flick" to the correct orientation after a short time.

If I make all my objects sync in world space they are positions correctly but on a dedicated client they will of course lag behind the body which is unacceptable of course.

Anyone have any knowledge on what has changed for local syncing? Do we need to migrate in some way, or perform initialisation etc differently?

NOTE: All this was working fine in 1.0.0 albeit the interpolation was broken (a known issue);

ashwinimurt commented 2 years ago

Backlog MTT-4517

NoelStephensUnity commented 2 years ago

Hello @akoolenbourke ! Do you have a project that replicates this issue that I could look at? This would help me test the issue against a shortly up-and-coming hot-fix patch specifically for NetworkTransform.

If not, could you clone/download this branch and see if those updates resolve your issue?

akoolenbourke commented 2 years ago

Hi Noel, sorry I don't have a repro for it, I haven't had the time to try and isolate it. I will try with that branch when I have some time and report back here.

Is there anything special I need to do to try a dev branch of a package? I downloaded the code zip from the link you supplied, added a package by file, pointed to the downloaded package. It seemed to import OK and the .json file was pointing to the folder I downloaded. However, the issue still exists.

Thanks

DavidGoedicke commented 2 years ago

Hey Noel, Thanks for working on this hotfix! I have e same problem. I tried it with your branch, but it still doesn't work. If it helps, I'd be happy to invite you to the git project if that helps.

Here is a picture where you can see that the wheels and the steering wheel are about 100 meters from the car. XCDriving-simulator

Let me know if I can add you to the repo/should try something else.

cheers David

NoelStephensUnity commented 2 years ago

If you wouldn't mind inviting me to your repo, it would help me troubleshoot this issue quicker. 👍

NoelStephensUnity commented 2 years ago

@DavidGoedicke @akoolenbourke Could you grab the most recent update of the hot fix branch?

I was fixing an issue with the initialization of the interpolators and left out the InLocalSpace check. >.< It should now properly initialize the interpolators with the world or local space values on the non-authoritative side during spawn.

DavidGoedicke commented 2 years ago

You should have an invitation: I am updating to the new version on the cathartic-reconciliation branch.

https://github.com/FAR-Lab/CrossCulturalDriving2021/tree/cathartic-reconciliation

I do have to apologize for the messy repo. I usually build to windows, and then click Start as Server in the build and then Start Client A inside the Unity editor to see the client behavior.

Assets\Prefabs\XE_Rigged_Networked.prefab Is the main vehicle that I spawn. Inside that prefab look for FL_PARENT It is the anchor for the Front Left wheel, which is synchronized over the network.

DavidGoedicke commented 2 years ago

I just tried the new update and the issue still persists.

NoelStephensUnity commented 2 years ago

I am looking at the packages and they seem to be all installed but not finding the "Rerun" namespace.

DavidGoedicke commented 2 years ago

Sorry about that. There is sadly no easy way to exclude it. I also invited you to the Rerun repository. It in turn uses the Ultimate Replay 2.0package https://assetstore.unity.com/packages/tools/camera/ultimate-replay-2-0-178602

Let me know if there is any other way I can help, or you run into more problems.

NoelStephensUnity commented 2 years ago

Ok, this requires additional packages that I would need to go through the normal bug submission process that includes the repository. Is there any way I could get you to send me the Network Prefabs you are parenting without any of the third party components? I really just need to know:

  1. What the parent and children are
  2. What the parent and children's' local position, rotation, and scale are
  3. The code segments that spawn and parent the children

This would help me to replicate the fundamental issue you are seeing.

My current guess is that you have 4 tires and 1 car (frame) and my assumption is that you are spawning everything and parenting everything in the same region of code/scope?

DavidGoedicke commented 2 years ago

Yes! I totally get it. Let me try to recreate the issue in a minimal example.

One thing I know is that I don't spawn the children separately, they all get spawned from one prefab and are owned by the server. I'll get right on this.

DavidGoedicke commented 2 years ago

Hey Noel,

I created a branch NetworkedTransformsDebug that should not include any 3rd party libraries.

https://github.com/FAR-Lab/CrossCulturalDriving2021/tree/NetworkedTransformsDebug

The Front Left wheel Example in the XE_Rigged_Networked prefab NetworkedTransforms

Here are the lines of code that spawn the vehicle once someone connects.

https://github.com/FAR-Lab/CrossCulturalDriving2021/blob/ebbc6efd623db417f41b879c33d225e1838b2c02/Assets/ConnectionAndSpawing.cs#L391

DavidGoedicke commented 2 years ago

I checked and InLocalSpace is set to true also when spawning it.

This picture shows the client running in the editor. We are in the waiting room scene. The Front Right pivot is selected with the network settings visible in the inspector.

InLocalSpace

NoelStephensUnity commented 2 years ago

Ok, I think I am seeing where there could be an issue. It looks like all of the anchors have NetworkTransforms that fall under the same NetworkObject. This is what I needed to create a test to replicate the issue on my side.

akoolenbourke commented 2 years ago

Ok, I think I am seeing where there could be an issue. It looks like all of the anchors have NetworkTransforms that fall under the same NetworkObject. This is what I needed to create a test to replicate the issue on my side.

Sorry I hadn't gotten around to a repro for you but I had mentioned that in the OP - multiple NetworkTransforms under a single NetworkObject is where it seems to die.

Good luck and thanks for taking the time to look at this

NoelStephensUnity commented 2 years ago

@DavidGoedicke @akoolenbourke I think I figured out the issue. If you grab the same branch (the updated version): https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/tree/fix/networktransform-extrapolation The issue (that I found on my end using a much simpler replica of what your project) was that the authority side wasn't using local space to initially set the position, rotation, and scale during OnNetworkSpawn. Based on what I am seeing in my manual test that replicated the same "relative conditions" (i.e. multiple NetworkTransforms under the same NetworkObject all with different local space offsets), the coming hot-fix should resolve your issue.

DavidGoedicke commented 2 years ago

Ok, so I think it's working. The wheels are now in the correct space.

Only interpolation is still broken. If I keep interpolation on the wheel keeps bouncing back and forth i.e. it looks like the 360 roll over does not fully work. For me, this is not a big problem, as the CrossCulturalDriving project is LAN only.

One thing that I am not sure about is if the IsLocalSpace is checked, does that also change the meaning of the Sync options for position and rotation? i.e. does it now reference its local rotation relative to its parent or still relative to global?

NoelStephensUnity commented 2 years ago

It means that any local space changes will be synchronized if the changes exceed the threshold (local space relative). You should also make sure any changes you are applying to the wheels are applied to transform.localRotation and not transform.rotation as that would cause visual artifacts.

does it now reference its local rotation relative to its parent or still relative to global?

Local space (for child objects) is always "local relative to the parent". It might be that the immediate parent is in local space as well...so the first parent/grandparent/etc where world space is applied... that is what the child's local space values are relative to. If there is no parent then obviously the local space is relative to the root/world space.

As an example, the image below shows nested parenting where all of the children have their local space values (relative to one another and the RootParent) displayed: image

The next screenshot shows what the Child object looks like "world space relative" (which is pretty much the sum of each parent's local space values plus the Child object's local space values: image x--> 10 + 5 - 2 --> 13 y--> 5 + 5 - 2 --> 8 z--> -10 + 2 --> -8 So, really think of it this way: With no parent you are setting the transform's "local space" values "relative to the world". Now, this ties into NetworkObject.TrySetParent (which will invoke Transform.SetParent) and the "WorldPositionStays" property. If you wanted to parent the new GameObject (assume it has a NetworkObject) you could keep its current world position "relative to the parent" or you could opt to not keep the world position (WorldPositionStays = false) which will still preserve the local space values (5,0,5).
The original "world space" relative "local space position" where our position is 5,0,5: image

There is a known bug with WorldPositionStays not synchronizing properly, but there is already another PR fix for this that will come in the update shortly after the hot fix. So, once that is fixed then it can be useful when parenting objects as well.

World Position Stays (True): image

World Position Stays (False): image

Which if we then move it back to the root/world as the parent: image

The "world space relative" local space position of the "GameObject" is completely different than the original 5,0,5 "world space relative" local space position.

akoolenbourke commented 2 years ago

Thanks Noel. I will try the new fix tomorrow to see if it helps me - however I see you mention that in order to have localSpace syncing work now, the localPosition etc need to be the property that gets changed. Does that mean we unable to have local syncing (i.e. sync relative to parent) but at the same time move/rotate objects in world position (transform.position and transform.rotation)?

Will try the hotfix tomorrow.

DavidGoedicke commented 2 years ago

Thanks for the explanation and hotfix, Noel. Any idea when the hotfix will go live?

NoelStephensUnity commented 2 years ago

@akoolenbourke

however I see you mention that in order to have localSpace syncing work now, the localPosition etc need to be changed When you spawn the NetworkObject, the authoritative side basically "teleports" the object which effectively sends a full state update of the network transform.

When joining players are synchronized with NetworkObjects the transform information (currently just position and rotation) should be the most recent values from the server.

If a child NetworkTransform is set to local space, it just means that it will synchronize the localPosition, localRotation, and localScale (relative to the axis marked to be synchronized). So, while the NetworkTransform is in local space (InLocalSpace) mode:

Are we unable to have local syncing (i.e. sync relative to parent) but at the same time move/rotate objects in world position (transform.position and transform.rotation)?

Since you have 5 NetworkTransforms (I think it is only five...the car itself and the 4 tires/wheels) and the tires/wheels NetworkTransforms are set to local space and since the car is set to the default world space mode, you will have both world space and local space synchronization. World space deltas are measured when setting the car's transform.position and transform.rotation to values above their respective threshold values. Local space deltas are achieved by changing the child's transform.localPosition and tranaform.localRotation.

As an example: If you had a parent (world space NetworkTransform setting) and a child (local space NetworkTransform setting):

You would change the parent's transform.position and transform.rotation to get a world space relative movement and rotation for both the parent and the child. The child keeps its local space values until they are changed via transform.localPosition and transform.localRotation. All of the parent NetworkTransform (world space) deltas will move both the car (frame) and all of the tires/wheels will their local space transform values that offset them from the parent's transform.position/rotation.

So, with the tires/wheels I am thinking the Yaw/Y-Axis local space rotation (turning wheel) and X-Axis pitch (tires/wheels spinning while moving) should be all that you need to synchronize for the tires local space rotation. With the tires position (i.e. bouncing on bumps/simulating shock absorbers) you should only need to synchronize the Y-Axis of the local space position (up and down). As long as you are only updating the local space X & Y rotation axis (Euler) and the Y position axis, it should all remain relative to the car's forward, up, and right vectors (i.e. relative to the car's rotation) and the tires' positions will be each tire's localPosition plus the car's transform.position.

NoelStephensUnity commented 2 years ago

@DavidGoedicke

Thanks for the explanation and hotfix, Noel. Any idea when the hotfix will go live?

Absolutely more than welcome! Thank you for being patient while we fix some of the issues and for using Netcode for GameObjects! :)

To answer your question: It is entering into the "pipeline" sometime today and should be available by next week (it is expected early next week, but sometimes it takes a day or two longer than expected to get promoted and become visible within the editor's package manager).

akoolenbourke commented 2 years ago

Thanks Noel. I thought it should be as such (re local space) so that's great to hear even if world is updated that the local will be synced too. I am going to try the hotfix soon. Hopefullly the interpolation is all good too as that's what we were initially wanting the update for.

Much appreciate the quick response

NoelStephensUnity commented 2 years ago

I am closing this issue at this time as the issues have been addressed and the fixes will be available in v1.0.2 (hotfix).
👍

akoolenbourke commented 2 years ago

Am I blind, but the link seems to be broken. https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/tree/fix/networktransform-extrapolation

NoelStephensUnity commented 2 years ago

@DavidGoedicke @akoolenbourke The v1.0.2 update is currently available via the Package Manager. Let me know if this resolves your issues?

akoolenbourke commented 2 years ago

@NoelStephensUnity Thanks Noel. My brief test this morning showed it looking much better but there still seems to be an issue. While the wheels are generally in the correct position, sometimes I can see that they snap to an orientation they shouldn't. That is, the wheels are rotating obviously (X axis) and they turn (Y Axis) but then sometimes they snap along Z and end up wonky. So far this only seems to be happening on dedicated clients. Host seems OK. I haven't tried builds and we haven't seen this issue n 1.0.0 - these are just preliminary tests so far.

This is what the wheel looks like on the host image

And this is what the client is showing image

Our setup is a few levels deep. We have

Base car - sync in world -Rotator child - sync in local --Visual - sync in local --- Wheel - sync local ----Wheel Vis - sync local

I am guessing we could turn the Z rotation syncing off but I'd still be interested as to why this is happening?

Thanks

NoelStephensUnity commented 2 years ago

@akoolenbourke I haven't had a chance to fully familiarize myself with your code base, but one quick question: Does the VehicleController only run on the server or does it run on the clients as well? Particularly, I am looking at the FixedUpdate and the forces it is applying to the vehicle and the wheels of the vehicle.

akoolenbourke commented 2 years ago

Hi Noel, it was @DavidGoedicke that gave up some source, we haven't been able to. Our game is server authoritative so nothing of control should be running on the client - our main car controller is disabled on dedicated clients so none of the code is running there. I went and checked and noticed we had some visual wheel code still running, however when I fixed that, the problem still showed.

Is there anything between 1.0.0 and 1.0.2 that would make the difference there? That is, even if there was code running on the client, wouldn't the NetworkTransform fix it all up so it's correct (Server authoritative)

I added some logging to wath the x axis of the local rotation euler angles and I see them drift over time. If I turn off interpolation (leaving local sync on) then the values start at 0, change to something very small decimal, and sit around there and don't, in my limited testing, move from there. Definitely not at the pace the interopolated ones do.

Not sure if that helps.

NoelStephensUnity commented 2 years ago

@akoolenbourke What are your rotation threshold level settings for the offending NetworkTransform(s)? As well, do you have any scale adjustments that occur at any point prior to seeing this issue?

akoolenbourke commented 2 years ago

@akoolenbourke What are your rotation threshold level settings for the offending NetworkTransform(s)? As well, do you have any scale adjustments that occur at any point prior to seeing this issue?

@NoelStephensUnity Our thresholds on the problem wheels are

Position: 0.001 Rot Angle: 0.01 Scale: 0.01

Yes, we do scale these wheels. The instantiated car is a base prefab, which we then go through and scale some parts based on configuration information for what type of car it actually is. We adjust the localScale, localPosition and localRotation immediately after Instantiate() and then when that construction function returns we SpawnWithOwnership.

NoelStephensUnity commented 2 years ago

@akoolenbourke Ahh... Yeah, this possibly could be related to the parenting issues that should be resolved in PR-2146. This branch is up to date with the develop branch so it should include everything that is in the v1.0.2 update with some additional parenting fixes. You could try disabling the scale adjustment to see if the wheels do align properly... if they do when the scale doesn't change then you might try that branch to see if it resolves this issue.

If you do use that branch, then I would recommend that when you are parenting the wheels you should use the NetworkObject.TrySetParent(parentTransform, false) method while setting the WorldPositionStays value to false. If you remove the parent, you can now still use the same method and WorldPositionStays value used to parent but pass null ( NetworkObject.TrySetParent((NetworkObject)null, false)).
(going to be updating the documentation about these updates)

Otherwise, if you don't have the time then I would need some form of hierarchical reference of your vehicle to make sure I am getting a close replication of that as well as:

akoolenbourke commented 2 years ago

Hi @NoelStephensUnity . Would that PR also affect the situation where things are not manually parented? We just instantiate a prefab with the hierarchy already setup.

I turned off setting of the localScale and the issue still persisted.

Thanks

NoelStephensUnity commented 2 years ago

Really, since your wheels still need to have a NetworkTransform for rotation and Y axis motion you might also try synchronizing scale too (if you are not already doing this).

Would that PR also affect the situation where things are not manually parented? We just instantiate a prefab with the hierarchy already setup.

Could you explain this a bit further? PR-2146 solves the issue where parenting on the server-side with WorldPositionStays set to false would not be synchronized with currently connected clients nor with late joining clients.

akoolenbourke commented 2 years ago

Yes we are already synchronising scale.

Could you explain this a bit further? What I meant, was does the PR also help solve an issue for children in a prefab and not just children parented through code? Ours is the former. From your further explanation it seems it's unrelated to our problem.

NoelStephensUnity commented 2 years ago

@akoolenbourke Could you send me the transform values for each of these objects when the Z axis rotation issue occurs and possibly the values just prior to when it occurs? Base car - sync in world -Rotator child - sync in local --Visual - sync in local --- Wheel - sync local ----Wheel Vis - sync local

Just trying to see if this is just local to one or all of the children.

NoelStephensUnity commented 2 years ago

@akoolenbourke I think the following branch from PR-2146 will resolve your scale and rotation issue. It should make it into the next update. Since it isn't possible to access your project, could you verify that the slight rotation issue gets resolved when using the above branch?

akoolenbourke commented 2 years ago

Hi @NoelStephensUnity. I tried to install and run that branch but on Parrelsync clones I get this error

KeyNotFoundException: The given key 'Unity.Netcode.ConnectionRequestMessage' was not present in the dictionary. System.Collections.Generic.Dictionary2[TKey,TValue].get_Item (TKey key) (at <e40e5a8f982c4b618a930d29f9bd091c>:0) Unity.Netcode.MessagingSystem.SendPreSerializedMessage[TMessageType] (Unity.Netcode.FastBufferWriter& tmpSerializer, System.Int32 maxSize, TMessageType& message, Unity.Netcode.NetworkDelivery delivery, System.Collections.Generic.IReadOnlyList1[System.UInt64]& clientIds) (at Packages/com.unity.netcode.gameobjects/Runtime/Messaging/MessagingSystem.cs:502) Unity.Netcode.MessagingSystem.SendMessage[TMessageType,TClientIdListType] (TMessageType& message, Unity.Netcode.NetworkDelivery delivery, TClientIdListType& clientIds) (at Packages/com.unity.netcode.gameobjects/Runtime/Messaging/MessagingSystem.cs:494) Unity.Netcode.MessagingSystem.SendMessage[T] (T& message, Unity.Netcode.NetworkDelivery delivery, System.UInt64 clientId) (at Packages/com.unity.netcode.gameobjects/Runtime/Messaging/MessagingSystem.cs:612) Unity.Netcode.NetworkManager.SendMessage[T] (T& message, Unity.Netcode.NetworkDelivery delivery, System.UInt64 clientId) (at Packages/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:1901) Unity.Netcode.NetworkManager.SendConnectionRequest () (at Packages/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:1618) Unity.Netcode.NetworkManager.HandleRawTransportPoll (Unity.Netcode.NetworkEvent networkEvent, System.UInt64 clientId, System.ArraySegment1[T] payload, System.Single receiveTime) (at Packages/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:1736) Unity.Netcode.NetworkTransport.InvokeOnTransportEvent (Unity.Netcode.NetworkEvent eventType, System.UInt64 clientId, System.ArraySegment1[T] payload, System.Single receiveTime) (at Packages/com.unity.netcode.gameobjects/Runtime/Transports/NetworkTransport.cs:49) Unity.Netcode.Transports.UTP.UnityTransport.ProcessEvent () (at Packages/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs:820) Unity.Netcode.Transports.UTP.UnityTransport.Update () (at Packages/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs:890)

I deleted the recreated the clone but still get it. I noticed the Unity transport version is now 1.2 so not sure if that has something to do with it.

NoelStephensUnity commented 2 years ago

@akoolenbourke Yes, you should update to the v1.2.0 version of UnityTransport. Let me know if that resolves the issue above?

akoolenbourke commented 2 years ago

Hi @NoelStephensUnity. Unfortunately it doesn't - I still get the same error. I downloaded the source from the link above (https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/tree/fix/parenting-does-not-preserve-worldpositionstays-option)

Copied it into Packages and changes the packages-lock.json to the following

    "com.unity.netcode.gameobjects": {
        "version": "1.0.0",
        "depth": 0,
        "source": "file:com.unity.netcode.gameobjects",
        "dependencies": {
            "com.unity.nuget.mono-cecil": "1.10.1",
            "com.unity.transport": "1.2.0"
        }
    }

To bring in 1.2.0 of the unity transport and the exception still happens when I try to connect my dedicated client to my host. I had close down both Unity's before doing this.

Also, I noticed 1.3.0 of UnityTransport was available so I tried that - same problem.

NoelStephensUnity commented 2 years ago

@akoolenbourke Ahh... so backup your current manifest.json file and then update your manifest.json file with these two entries:

    "com.unity.netcode.gameobjects": "https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git?path=com.unity.netcode.gameobjects#fix/parenting-does-not-preserve-worldpositionstays-option",
    "com.unity.transport": "1.3.0",

Make sure there are no other entries for com.unity.netcode.gameobjects and com.unity.transport in manifest and then save it. When you switch back to or open your project in the editor it should work.

If the PR gets merged and it can't find the branch (and you want to continue using the fixes until the coming update) then change your com.unity.netcode.gameobjects to this:

    "com.unity.netcode.gameobjects": "https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git?path=com.unity.netcode.gameobjects#develop",

Which will have the merged PR in it. Let me know if this works better for you?

akoolenbourke commented 2 years ago

Thanks @NoelStephensUnity. Unfortunately those instructions generate the same error (I had to use #develop because the other didn't work).

This is the callstack I get on dedicated clients. Hosts can start up OK BTW, although later when I perform RPCs and try and serialise one of my own structs, it now throws a null ref exception. I took a look and see some of our fields would be null and previous versions would serialise (Both read and write) those without issue but not they seem to throw null refs. Anyway that's another issue.


KeyNotFoundException: The given key 'Unity.Netcode.ConnectionRequestMessage' was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <e40e5a8f982c4b618a930d29f9bd091c>:0)
Unity.Netcode.MessagingSystem.SendPreSerializedMessage[TMessageType] (Unity.Netcode.FastBufferWriter& tmpSerializer, System.Int32 maxSize, TMessageType& message, Unity.Netcode.NetworkDelivery delivery, System.Collections.Generic.IReadOnlyList`1[System.UInt64]& clientIds) (at Library/PackageCache/com.unity.netcode.gameobjects@8b2a8b7a59/Runtime/Messaging/MessagingSystem.cs:502)
Unity.Netcode.MessagingSystem.SendMessage[TMessageType,TClientIdListType] (TMessageType& message, Unity.Netcode.NetworkDelivery delivery, TClientIdListType& clientIds) (at Library/PackageCache/com.unity.netcode.gameobjects@8b2a8b7a59/Runtime/Messaging/MessagingSystem.cs:494)
Unity.Netcode.MessagingSystem.SendMessage[T] (T& message, Unity.Netcode.NetworkDelivery delivery, System.UInt64 clientId) (at Library/PackageCache/com.unity.netcode.gameobjects@8b2a8b7a59/Runtime/Messaging/MessagingSystem.cs:612)
Unity.Netcode.NetworkManager.SendMessage[T] (T& message, Unity.Netcode.NetworkDelivery delivery, System.UInt64 clientId) (at Library/PackageCache/com.unity.netcode.gameobjects@8b2a8b7a59/Runtime/Core/NetworkManager.cs:1930)
Unity.Netcode.NetworkManager.SendConnectionRequest () (at Library/PackageCache/com.unity.netcode.gameobjects@8b2a8b7a59/Runtime/Core/NetworkManager.cs:1647)
Unity.Netcode.NetworkManager.HandleRawTransportPoll (Unity.Netcode.NetworkEvent networkEvent, System.UInt64 clientId, System.ArraySegment`1[T] payload, System.Single receiveTime) (at Library/PackageCache/com.unity.netcode.gameobjects@8b2a8b7a59/Runtime/Core/NetworkManager.cs:1765)
Unity.Netcode.NetworkTransport.InvokeOnTransportEvent (Unity.Netcode.NetworkEvent eventType, System.UInt64 clientId, System.ArraySegment`1[T] payload, System.Single receiveTime) (at Library/PackageCache/com.unity.netcode.gameobjects@8b2a8b7a59/Runtime/Transports/NetworkTransport.cs:49)
Unity.Netcode.Transports.UTP.UnityTransport.ProcessEvent () (at Library/PackageCache/com.unity.netcode.gameobjects@8b2a8b7a59/Runtime/Transports/UTP/UnityTransport.cs:788)
Unity.Netcode.Transports.UTP.UnityTransport.Update () (at Library/PackageCache/com.unity.netcode.gameobjects@8b2a8b7a59/Runtime/Transports/UTP/UnityTransport.cs:858)
NoelStephensUnity commented 2 years ago

@akoolenbourke What version of Unity are you using? There was a recent update (this week) to make NetworkVariables handle managed types and this requires the most recent version of Unity (or higher) to use the current develop branch: 2021.3.11f1 LTS 2020.3.40f1 LTS 2022.1.19f1

That error you are getting will happen if you are using an earlier version than the above listed versions.

Once you have updated, let me know if you run into any further issues.

akoolenbourke commented 2 years ago

Hi @NoelStephensUnity I upgraded to 2021.3.11f1 (from 2021.3.5) and this issue still occurs on dedicated client editors as before. I deleted and recreated the clone as well as testing this on a real windows build and still the same issue. This is the NGO (And transport dependencies) I have installed, from the link you gave me the other day.

image

Here is my manifest.json image

NOTE: I am running on Windows (10) if that would matter at all.

NoelStephensUnity commented 2 years ago

Could you send me an example of the RPCs you try to invoke where you have issues (and the struct that seems to also have issues)? Also, when you say "dedicated clients" do you mean running clients from a stand alone build you create?

NoelStephensUnity commented 2 years ago

@akoolenbourke Could you share your manifest file and what platform are you compiling for?

Also, could you exit the editor, delete the Library/ScriptAssemblies folder, then re-open the editor and once it is done loading your project share the editor.log file generated? (we have a few people looking into this issue and this information will help us track down this issue).

akoolenbourke commented 2 years ago

Hi @NoelStephensUnity . I'm not trying to do RPC, I'm just trying to connect a client to the host with networkManager.StartClient(). My startup function (the one that calls StartClient) is async and returns a UniTask from a completion source I create. It's during the awaiting of returned UniTask that I get the exception and the callstack is entirely in NetCode which confuses me.

Prior to this develop branch with the world transform fix, 1.0.0 and 1.0.2 have been working find (Albeit 1.0.2 has that transform issue) and never showed the exception - our async connects were working fine.

Is there somewhere I can put a zip of the files where only you can get to them?

NoelStephensUnity commented 2 years ago

@akoolenbourke If you have a discord account then you could add me as a friend (my user name is nstephens and id is 0030), direct message me, and send a zip that way. =or= Within the Unity Editor, you can select Help-->Report a Bug In the title you can use Github Issue #2160 For the details just make a note that you are submitting a bug for us to troubleshoot an issue with v1.1.0 (develop branch). Include my name in the details as well. This should zip your project and submit it internally. When you are done let me know and I will get QA to grab the submitted bug that should have your project included as a zip.

NoelStephensUnity commented 2 years ago

Re-opened temporarily to track until an internal ticket was opened.
MTT-5024 was created to resolve the issue with nested NetworkBehaviours.