Unity 3d client control of server scene - unity3d

So I've searched for this for a while but I can't seem to find an answer. Here's my current state: i have a phone build of a scene which is the client and a pc build of a separate scene which is the server. I want the client scene to control the server scene. Image Jackbox TV but i'm not trying to use a web interface. I just want the phone to control the pc build. Every tutorial that I've searched through simply tells how to set up networking so that every instance of a player in a game is working in the same environment and getting all the correct variables. But I don't know how to send controls from one scene to the other. Can someone explain, even if it's just in "english code" how to do this? Something like
Add NetworkManager component to sceneA and sceneB
Setup functionA to pass variableA to functionB on sceneB
I'm not asking for an in depth coding lesson (although always appreciated), if someone could even give me the right things to google as are pertinent to my needs, even that would be wonderful.

Related

How can I sync local movement to Photon Network in Unity?

im making a multiplayer FPS game, and I have pretty much all the networking done and working. The issue is, that photon is syncing to players local movement, but if u have a bad connection, you could not tell it is happening cause player send late updates to the server and you can see other players lagging but you can move free and smoothly.
Im aware a lot of games work this way but i also know there are games like medal of honor that your player get stock in the last place every one else saw you. I need to know how to implement this on my game, because gameplay depends on it.
What you describe is "local prediction" of actions / movement.
If I understand this right, you want clients to not act or move if there wasn't a confirmation? If so, you'd need an authoritative host or server. You'd always wait for a confirmation from the host to move the player in any way.
But .. this is not going to work well. Players will feel the lag very much and this is annoying.
You probably want to predict the movement, then correct the local situation if the server disagrees.
I would recommend using Fusion instead of PUN for shooters. It can be run with host and has a nice API to reconcile the actual state from prediction to what the host simulated.

UMMORG/Mirror Networking - Moving A Connection From World To Lobby

I have been working for some time on a project using the UMMORG framework, which is built on Mirror networking. However, as of recent, I have been having an issue I just cannot solve.
In my project, when a player character is killed, I want the player to be moved from the game world back to the lobby. Or, in more technical terms, for the player's NetworkConnection to me moved from the Network State 'World' to the Network State 'Lobby.'
I have tried many times, but have been unable to find a way to do this. The consistent issue is with the player NetworkConnection not being found as a key in the Lobby dictionary. However, attempts to manually add the player NetworkConnection to the Lobby dictionary have failed. I'm assuming that Mirror requires a specific process to move a connection back to the lobby, but I just can't figure it out!
TLDR: How can I move a NetworkConnection in Network State 'World' to Network State 'Lobby?'
Thank you so much for your help! I will be checking this thread as often as I can, so if I haven't provided enough information, I would be happy to provide more. I have not changed any of the netcode in my UMMORG project, so if you have found a solution for this in your UMMORG or Mirror project, I would love to hear it! Thanks again!
Did you use MatchInterestManager?
I used MatchInterestManager and attach NetworkMatch to my player script.
Whenever I needed to change player state (for example from Lobby to Game or Game to Lobby), I simply change NetworkMatch.matchID from "lobby".toGuid to "gameName".toGuid.
Feel free to leave comments, and I'll do my best to answer.

Unity UNET How to change online scene in sync with clients

I'm using the old Unity 2017.3 UNET implementation in my game. Players connect to a server and are placed in a Lobby scene until the party leader selects another level to go to. The implementation is just a slightly modified version of the default NetworkLobbyManager.
The trouble started now that I've begun heavily testing the networking code by running a compiled build for a client and then using the editor as the server. Very frequently, the server running in the editor will run a great deal slower than the compiled client build. So when I use NetworkManager.ServerChangeScene the client will load the scene before the server, which will cause all NetworkIdentities on the client scene to be disabled (because they haven't been created on the server yet.)
It's a lot less likely to happen if the server is running a compiled build, because the server will almost always load the scene before any clients. But it does surface a bigger issue with Unity itself. That there's no guarantee that the server will be available when changing scenes.
Is there some other way of changing scenes in a networked game? Is there a way to guarantee that the server enters the scene before any clients? Or am I stuck just kind of hoping that the network remains stable between scene changes?
Well I thought about it more overnight and decided to look in other directions, because more investigation revealed that sometimes the Network Identities are still disabled when the server loads the scene first as well.
I was looking through the UNET source code and realized that the server should be accounting for situations where it loads the scene after the clients, although that code looks a little jank to me. This theory was backed up by the documentation I found that also says NetworkIdentities in the Scene on startup are treated as if they are spawned dynamically when the server starts.
Knowing those things now, I'm starting to think that I'm just dumb and messed some stuff up on my end. The object that was being disabled is a manager that enables and disables other NetworkIdentity objects. I'm pretty sure the main problem is that it's disabling a network identity on the client, that is still enabled on the server, which is causing the whole thing to go haywire.
In the future, I'm just going to try and stay away from enabling and disabling game objects on a networked basis and stick to putting relevant functionality behind a flag of my own so that I can "soft disable" an object without bugging out any incoming RPCs or SyncVar data.

Visual feedback for area learning and motion tracking in Unity

I'm getting pretty bad results with Area Learning, the localization takes very long and I have no idea what's happening. Did I map the area enough? Is there enough landmarks? Is the ADF alright? No clue.
Is there any way to provide a visual feedback while doing the actual motion tracking and area learning? I keep seeing it in Google videos but didn't find any way of doing it in the Unity SDK.
I would like something like this in my video overlay: https://youtu.be/NTZZCtmR3OY?t=10m57s
Btw my results in Unity are FAR worse than this demo, sometimes it takes minutes for the device to localize and only at a certain spot in the room, the next minute the very same spot doesn't work again. Quite frustrating. No idea what app the presenter uses, for instance, my ADF Inspector reliably crashes every time I try to load any ADF. (Using Wasat and recently I've deleted and re-installed everything.)
It is not supposed to be so. It should not be that bad, under the normal day light condition. If it is a small area, should be able to localize using ADF within 3-5 seconds. The video showed the usual case -- always like this.
If your kernel is up to date, and you are using the correct development kit. I would recommend you to reach the tango team customer service directly.
tango-help#google.com
Perhaps it is caused by your device defective. If so, ask for an exchange would solve the problem.

Unity - trading card game architecture

I'm trying to develop a TCG(trading card game) in Unity(I'm Unity newbie) and currently stuck on the architecture of the project and the card effects in particular. Coming from web development background for me all the logic and card effects should be on the server but going through some tutorials for Unity I think the logic should be on the client and I should use a simple room-based server to notify for player actions. Is that correct?
To summarize - where the game logic should be(e.g. card effects, rounds etc)? On the client or on the server?
I actually worked on one of the major TCG's out now for iOS/droid, so this is coming from experience. You definitely want all game logic and rules to be on the server. Do not trust your client to be the source of truth for any game outcomes etc. People will be able to hack that by tampering with the data sent back to the server. They don't have to decompile the game to do that, it can be done merely by sniffing the net traffic.
That said, you may end up with some duplicated logic on both client and server, only so that you can enforce game rules and display the outcomes without always hitting the server. However, your server is always the source of truth and the client is just there to accept input and display outcomes.
The general flow was the client would send a message requesting a new game to the server. The server would respond with the cards for each side and the opening move for the first player. Then the client would simply parse each move and display the outcome. On the cards objects we had methods for many of the actions, such as DrainHealth() and BuffAttack(). When called, these methods would trigger things like particle effects and sound fx attached to the card script.
Yeah the effects should be on the client, I assume your game will be turn based right? You might want to take a look at photon then:
https://doc.photonengine.com/en-us/realtime/current/getting-started/realtime-intro
They have a loot of good tutorials about their API and it's well documented :)
Hope that helps you,
good luck