I am using RemoveRPCs() and Destroy() on my clients and the server to remove game objects from inside an RPC call using this code:
GameObject GO = GameObject.Find(argShipName);
Network.RemoveRPCs (GO.GetComponent<NetworkView>().viewID);
Destroy(GO);
In the course of destroying the objects in my multiplayer game I am getting an:
“View ID AllocatedID: 51 not found during lookup. Strange behaviour may occur” error.
Here’s part of the merged log file from the two players and the server:
10:54:19.331 Playr1: GameSetupScript: Client class added to GameManager. P# 1
10:54:19.351 Playr2: GameSetupScript: Client class added to GameManager. P# 2
10:54:22.002 Playr1: FleetCreationDone: viewID: AllocatedID: 50
10:54:28.710 Playr2: FleetCreationDone: viewID: AllocatedID: 150
10:54:32.285 Server: PerformBattleModeTest
10:54:34.223 Server: RPC: AcceptBattleMode
10:54:34.227 Server: PrepareForBattleMode, P#: 1 F#: 0 Ships: 10
10:54:34.236 Server: PrepareForBattleMode, P#: 2 F#: 0 Ships: 2
10:54:34.248 Playr1: RPC: CreateShipsMessage - ship: P1S10 ViewID: AllocatedID: 51
10:54:34.260 Playr2: RPC: CreateShipsMessage - ship: P2S2 ViewID: AllocatedID: 151
10:54:38.025 Server: StartBattleMode
10:54:39.547 Server: RPC: SignalRetreat
10:54:49.614 Server: ExitBattleMode
10:54:49.615 Server: RPC: DestroyShipsMessage - ship: P1S10
10:54:49.619 Server: RPC: DestroyShipsMessage - ship: P2S2
10:54:49.628 Playr2: RPC: DestroyShipsMessage - ship: P1S10
10:54:49.638 Playr2: RPC: DestroyShipsMessage - ship: P2S2
10:54:49.643 Playr1: RPC: DestroyShipsMessage - ship: P1S10
10:54:49.644 Playr1: RPC: DestroyShipsMessage - ship: P2S2
10:54:56.691 Server: PerformBattleModeTest
10:54:56.769 Server: ExitBattleMode
The ship “P1S10” is apparently the one with the problem.
Note: Player#1 is the owner of the ship and generated the networkview ID for it.
Am I doing something wrong with the RPCs or the Destroy()?
Is the order the objects are being destroyed the problem?
Help Mr. Wizard!!!