SOLVED LAN Multiplayer not workin
-
tried from PC and Android on the same LAN.
Sometimes it works (usually the first time) but at the end pf a game if hit restart or if I quit and hit play:- sometimes it gives an error cannot connect,
- other times it gives the players connect and are in the same team (but the second one is spwned in the middle of the map inside the wall, and it pops out of the wall, effectively sitting on the wall)
- sometimes the games can't even find themselves and they just start new hosts.
- I also get the error:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
TanksMP.Pool+<DespawnInTime>d__13.MoveNext () (at Assets/TanksMultiplayer/Scripts/Pool.cs:225)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <17ad9609ae064f2c9315931ff97adcf1>:0)
The code contains the modifications you proposed in the previous two posts.
The only other modification is that it has the win condition to be 1 point (so I can iterate fast in testing)
I'll have to test some more to see the exact conditions how to reproduce each step -
Since I'm running on the latest Asset Store version (30.2.1), I am getting a Mirror bug even in the Mirror sample scenes, where Android devices cannot connect on LAN at all.
https://github.com/vis2k/Mirror/issues/2534
https://github.com/vis2k/Mirror/issues/2511I am still working on this, but have to test with 30.4.1 first, which could result in more errors. Hopefully the same errors you are experiencing.
Small update:
sometimes it gives an error cannot connect
other times it gives the players connect and are in the same team (but the second one is spwned in the middle of the map inside the wall, and it pops out of the wall, effectively sitting on the wall)This is an issue I mentioned in your other post and I am looking at that. It seems like Mirror is assigning both player objects (host and client) the same netId, 0.
sometimes the games can't even find themselves and they just start new hosts.
This is not what I am seeing - when hosting the game on a PC, the Android device can always connect. However, trying to host on the Android device, the PC is not able to connect. It could be caused by the Android device not supporting broadcasting or sending via the correct ports (47777 by default).
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
That error is caused by shooting a bullet and then quitting the game. I will investigate that, but it is not something that causes other problems right now.
-
Currently preparing an update for submission to the Asset Store. It should be available later today.
Upon testing, points 1 & 2 & 3 did not occur anymore on 10/10 game launches.
I discovered a rare issue with the device log getting spammed and a Socket exception, where the causing line is in the Mirror code itself. I hope you understand that I am not able to deliver fixes in Mirror within the asset, but if you run into that, the following if-catches should be added in the NetworkDiscoveryBase script.
async Task ReceiveGameBroadcastAsync(UdpClient udpClient) { // only proceed if there is available data in network buffer, or otherwise Receive() will block // average time for UdpClient.Available : 10 us if (udpClient == null) return; if (udpClient.ReceiveAsync() == null) return; //...