#Server kick out players
91 messages · Page 1 of 1 (latest)
I usually get this when an exception is thrown directly in a cmd on the server
be sure to check log files for both client and server
something has gotta be there
@gentle trench @rare dagger Thank you very much
I have realized something:
To give context, the game I'm working on is one where ideally you can play different characters. My solution was to pass an empty object as playerPrefab to the networkManager who would ask the server to create the character that the user would actually handle. This used to work great, no problem. But now as soon as the player asks the server to create the playable character, it throws me the error that I mentioned in this post. The only new thing I've done is some logic to load scenes asynchronously to load different maps.
I did a test where the player instead of requesting the playable character from the server, instantiated a simple cube and the error did not appear.
basically this happens after this line:
@gentle trench what do you mean with too soon?
@rapid jungle can you see this post?
So to explain MrGadget, as I mentioned in other thread. From my project:
- I connect to server Aka start client
- Send custom network message to spawn character;
Will not work. As it run in one frame, both these commands is too slow to happen one after each other. - I connect to server Aka start client
- wait several frames
- Send custom network message to spawn character;
This variant works, as it have time to start server, initialize stuff and then do your stuff.
But for this exact logic I am confusing with you spawning. As you pretty much adding character twice.
as after this: NetworkServer.AddPlayerForConnection(conn, gameobject); you already spawned player and assigned them with the player prefab. and then immediately you send another message, to Spawn another network object which authority belongs to a user? So one connection have authority over 2 objects?
Player can be kicked out if there is an error on player object or somehwere on server, as it is security measure. Please check logs
@austere coral The player object that Mirror creates automatically makes a request to the server to create a playable agent. I did it this way because the player should be able to play with different skins and characters, like in overwatch there are different characters with abilities and attributes
The problem is that this was working fine before, until I added logic to load the game maps additively
Then maybe that is where you should look for problems. How do you load those additive scenes? Manually? over mirror? maybe there is a script that runs on start on the scene and reference is not there anymore, it could give you null reference and that will kick player off. The Error can be server only. so both logs needs to be checked
@austere coral
You assume that server and client will change scene at the same time?
Have you checked the example scene in mirror folder for additive scenes?
no
yes
i wait till server loads scene and client
since I am sending the message to the client to load a scene, I am sure that the method OnClientChangeScene will be executed
ReadyToPlay its the method that calls the cmd to create the playable agent
why are you not just using
https://mirror-networking.gitbook.io/docs/community-guides/quick-start-guide#part-16
Written by JesusLuvsYooh / StephenAllenGames.co.uk, edited by James Frowen
you are making your life difficult with custom implementation when you can go way easier way that is already implemented.;
As then you dont need to take in account that something is not spawned and etc. which problems you have now.
as you youse load async, not aditive there will be no difference.
That was my first try, but I have some scripts that repeat every scene, the minimum necessary for the game to work. So the online mirror scene has those scripts, so the map scenes just have the maps and no logic, since the base scene already has it.
It's not making life difficult, it's a requirement for the way the game works, as I told you, in our game each round is a different map so I must be able to change the scene with the ability to continue using things like, the script that saves the points in the database, ui , player manager and deaths etc
if you change scene, you requere respawn players, make sure they all ready and server is ready before spawning and etc. so thats why I suggest use mirror scene changes rather than your own. As it isjsut harder
For things that saves data you you DOL (dont destroy on load) objects, which stays even if you change scene.
to be honest, this error appears after building a server for playfab, it worked fine locally, but after building for plyafab it doesn't even work locally
have in mind they cannot be objects with network identity, for reason that all objects are beeing disabled with netowrk identity until player is SPAWNED.
Oh playfab. I noticed people have a lot of problems with it recently 😄 Well working localy and remotely is always different if you code is not prepared. Expecially with Timing is very different. And even depends on system functions: findFirstordefault can return different results and etc. so it is important to test throughfully.
Example: Had two event managers one for you one for character. Localy it worked perfectly, my collegue got same version. didnt work at all. as for him different event manager were selected first by default. Have in mind identical project, just different PC.
I still think main problem you have is spawning is out of order, or calling commands too fast.
You can try create buttons for each action and make sure at which it fails.
I'll try with some delays
and once again, try using as much mirror examples as possible, as there is quite a lot of things behind the scenes, especially with scenes changing. So it is super highly recommended to use mirror functions.
actually my logic is based in one mirro example
there is an example called additive scenes
i just made a test were im not using additive scenes and the error persist after create the agent
lol
im dead
2 weeks stuck
i wanna cry so bad
To be honest idk if OnClientChangeScene is called when you use additive scenes 😄
unles you change active scene? jsut a guess tho.
Okey lets clear things: YOU CHANGINGS SCENES OR ADDING ADDITIVE SCENES?
I know how you feel, I was in your shoes before
I'm using additive scenes, BUT in order to test if they really are the problem I did a test where I don't and just load the online scene and create the character. But the error persists
And it is only on Playfeb or locally as well?
locally as well
Im using parrel sync
I'll make a test just making a build
hold on
Jajaja
sorry For security reason I cannot open any files on this pc 😦
I'm pretty sure the scene handling logic is good
I know I missing something but i dont know what,
as you can see, for example, my logic works perfectly with the loading screen
For me it still looks like your timing is off. What with resuming handlers after scene was loaded Debug line?
And I'm sure you're right
why ypu have autocreate player option on?
let show
bad idea?
well you handling your spawning manually right? so there is small chance that it add player object for you, than it tries to run code and you add another player object, and the handlers got double call or something
ok let my try brother
Either follow the logic of additive scenes in Aditive scenes examples of mirror. The examples folder have pretty clean code.
I would spawn character on network message. And send network message when I know that everything is loaded 100 % on client.
works
man i told you the scene handling logic is so good and is pretty clean as well 100% you will fall in love with my code
200%
You connect to server. You load scene on server. Then you load scene on client. When scene is loaded on client to send network message to server asking to spawn. The server checks if scene is loaded, then if it is true it spawns. that would be secure way to do.
You were right the problem was to create the character automatically
10/10 your help man
Noticed that on accident. Glad you found a way. Just dont forget, never assume client and server have same timings 🙂 golden rule of netowrking 😄 well it seems not this time tho 🙂
@austere coral Hi! how are you doing?
good, have any more problems?>
working locally but not in playfab ajajj]
sorry, havent touch playfab at all, so cant help on that section