InvalidCastException when NetworkAnimator removed from gameobject
See original GitHub issueThis 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:
- Created a year ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mrwillt1986 I am definitely pushing for this process, and this is what I told the user who filed issue #2188:
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.
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?