question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InvalidCastException when NetworkAnimator removed from gameobject

See original GitHub issue

This is being spammed hundreds of times a second when a network animator gets removed from a gameobject. The client in my game doesn’t send the server any animation, so the networkanimator gets removed from the gameobject as there is no other way to disable the network animator.

InvalidCastException: Specified cast is not valid.
Unity.Netcode.Components.NetworkAnimator.__rpc_handler_1069363937 (Unity.Netcode.NetworkBehaviour target, Unity.Netcode.FastBufferReader reader, Unity.Netcode.__RpcParams rpcParams) (at <b7c09b1b80264f9da254262437a7e141>:0)
Unity.Netcode.RpcMessageHelpers.Handle (Unity.Netcode.NetworkContext& context, Unity.Netcode.RpcMetadata& metadata, Unity.Netcode.FastBufferReader& payload, Unity.Netcode.__RpcParams& rpcParams) (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Messaging/Messages/RpcMessages.cs:77)
Rethrow as Exception: Unhandled RPC exception!
UnityEngine.Debug:LogException(Exception)
Unity.Netcode.RpcMessageHelpers:Handle(NetworkContext&, RpcMetadata&, FastBufferReader&, __RpcParams&) (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Messaging/Messages/RpcMessages.cs:81)
Unity.Netcode.ClientRpcMessage:Handle(NetworkContext&) (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Messaging/Messages/RpcMessages.cs:154)
Unity.Netcode.MessagingSystem:ReceiveMessage(FastBufferReader, NetworkContext&, MessagingSystem) (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Messaging/MessagingSystem.cs:457)
Unity.Netcode.MessagingSystem:HandleMessage(MessageHeader&, FastBufferReader, UInt64, Single, Int32) (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Messaging/MessagingSystem.cs:387)
Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue() (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Messaging/MessagingSystem.cs:407)
Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate() (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:1536)
Unity.Netcode.NetworkManager:NetworkUpdate(NetworkUpdateStage) (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:1468)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage(NetworkUpdateStage) (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.<>c:<CreateLoopSystem>b__0_0() (at External/com.unity.netcode.gameobjects/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:208)


Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
NoelStephensUnitycommented, Oct 7, 2022

@mrwillt1986 I am definitely pushing for this process, and this is what I told the user who filed issue #2188:

There are still ongoing discussions about certain areas within the SDK that could be improved and this issue is being added to the list of things that still need to be properly mapped out/discussed in order to determine the best approach. This means a fix for this is not likely going to happen in the next update (or two).

So, this is something I can’t make a definitive ETA on as it really depends upon how these changes align with other targeted improvements being discussed and if there are any cross dependencies. I definitely am in favor of improving this area of code and will continue to help drive for a better solution.

0reactions
mrwillt1986commented, Oct 7, 2022

Its going to be a real pain I have to admit, but if its all I have to work with then I can work on something that will work.

Do you know if Unity have plans to solve this in the near term?

Read more comments on GitHub >

github_iconTop Results From Across the Web

InvalidCastException: Specified cast is not valid.
Hi Everyone Am trying to creating an card game in which player can attack on enemy card in Battlezone. if players attack power[A.P]...
Read more >
Unity Mirror, Client is not executing damage Command
I have a script on the Player that gets its target by clicking on them. I check if the players auto attack cooldown...
Read more >
Network Animator
The Network Animator ensures the synchronisation of GameObject animation across the network - meaning that all players see the animation happen at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found