Skip to main content
8 votes
Accepted

How can I use websockets in a Unity WebGL project?

As the documentation says, The Unity scripting API does not expose direct WebSocket access itself. But you can access the native web browser API by calling JavaScript from Unity C# scripts. Create a ...
Philipp's user avatar
  • 120k
6 votes
Accepted

When to use Command and RpcClient

Background In normal client-server games, the server is authoritative meaning it has the final say over how the games state exists and is in charge of making sure the clients know the current game ...
Cobertos's user avatar
  • 1,644
4 votes

How to store and retrieve user data in a multiplayer game

Unity does not include a server side persistence solution out of the box. As far as I can tell the only storage solution Unity includes is PlayerPerfs, but that is client side. However that does not ...
Theraot's user avatar
  • 27.2k
4 votes

Difference between [P2P] Relay Servers and Dedicated Game Servers?

In the peer-to-peer client-server model, the server software runs on the machine of a player who is also taking part in the game. The server software and the game client are usually integrated in the ...
Philipp's user avatar
  • 120k
4 votes
Accepted

How can I secure my data in Unity?

What is in clients hand is by definition not secret anymore. Regardless what you do, if they are dedicated enough they can get the information that is located inside the client. Instead why not let ...
Zibelas's user avatar
  • 4,346
3 votes
Accepted

Unity 5: Use Network Simulator, should I?

For anyone looking for good network simulation software go here https://jagt.github.io/clumsy/ Clumsy doesnt need installed or anything, just run it and specify your parameters. I realise it is really ...
CH99's user avatar
  • 563
3 votes
Accepted

Unity and Thread for Reading UDP

Well, I stumped our local unity expert also, but we did a debug session in my office and after about an hour, we found out it is not the code. The Unity IDE will report console messages even focus is ...
Dr.YSG's user avatar
  • 179
3 votes
Accepted

Why nobody creates shared world games?

Yes there are games, and yes there are problems. Listen, light has a set speed. Even if the connection were at light speed all the way from client to server (which probably it isn't), it takes time ...
Theraot's user avatar
  • 27.2k
3 votes

Is this enough calculation on server-side to be secure?

Is wrong. Changing states of objects is trusting the client. Depending on what that object does, nothing would prevent the client from keeping it alive or setting it dead. The question does not state ...
Zibelas's user avatar
  • 4,346
2 votes
Accepted

Unity Network Flip sprite renderer

[ClientRpc] functions are only called from the host. For the Client to send to the Host, you need a [Command] function, or serialize a variable.
Stephan's user avatar
  • 1,728
2 votes
Accepted

Random Disconnects on UNET

you can try changing delay value in Network Manager from 0.01 to any higher value. 0.9 worked normally for me.
Nick's user avatar
  • 561
2 votes
Accepted

How to give and remove authority of an object between multiple clients (Or how to let the client controller push a rigidbody)

And so here's the script I used to solve this problem. However, if both client and host are sending commands through the object, you'll have a problem when the client has authority. I'll try to solve ...
Studio Pie's user avatar
2 votes
Accepted

Unity Networked gaming 2019... What happened to NetworkBehaviour, OnServerStart() etc

As of right now, there is no production ready replacement for UNET. UNET is currently deprecated. UNET has four main components, HLAPI, LLAPI, relay server, and legacy matchmaking. The HLAPI will be ...
Landon's user avatar
  • 141
2 votes

Prevent multiple input packets to authoritative server

Have clients stamp their input packets with the index of the 30 Hz input window to which they correspond. On the server, keep a bitmask of windows for which you've received input from each client. You ...
DMGregory's user avatar
  • 135k
2 votes
Accepted

Synvar not syncing when Instantiating gameObject

I found a workaround using netIds. I think the problem was that when I tried to sync the gameobject, it wasn't spawned yet on the client, so it was null. ...
ToltottKaposzta's user avatar
1 vote

How do you get audio clips to play on all clients?

The specifics of Unity networking kind of fly right over my brain, but here's a rough conceptual model to how a game would conventionally handle this. 1. Client 1 tells the server "I'm shooting my ...
Huxellberger's user avatar
1 vote

2 cameras that each player sees through a different one

That's not how your online game will work. When playing on separate computers, you'll still only have one camera active at a time. There will be two instances of the game being run, clients A and B. A ...
House's user avatar
  • 73.3k
1 vote
Accepted

Unity3d multiplayer canvas

You method makeItRed is a static method which sets a variable which is most likely also declared as ...
Philipp's user avatar
  • 120k
1 vote

How to receive broadcast message in Unity?

I had the same problem. Turns out the class that inherits from NetworkDiscovery is not allowed to have it's own Update() function.
joon's user avatar
  • 553
1 vote

Using unity app how to read the asset in android SDCard?

To solve this problem I created pre-compilation script which will run before the compilation; this script will list the names of the files you want to access later in text file ...
Shady Mohamed Sherif's user avatar
1 vote

Why is the ownership fixed when synching objects?

I can't say why the ownership is fixed. But that being the case I'd suggest making two cue balls, one owned by each client. Only make one visible at a time based on whose turn it is. Then after ...
CLo's user avatar
  • 1,330
1 vote

Send Rate is zero but server movement is still happening

It looks like this API is set up so that a send rate of 0 means "on demand". If you're continually moving an object that's been set to, say, 10 network updates per second, those transform ...
DMGregory's user avatar
  • 135k
1 vote

How do I Sync data from client to server?

Not sure if this has been figured out or but here goes. I dropped the [SyncVar] portion except for health and shields on players and used the following code to get by break lights to sync across ...
chatbear69's user avatar
1 vote

Unity - DontDestroyOnLoad - FindObjectsOfType(GetType()).Length is always returning 1

Try this. It compares time alive on different instances of the class, ensuring that your first instance will be the one that survives. ...
Samuel Lopes's user avatar
1 vote
Accepted

How do I use Unity's OnPlayerConnected method?

OnPlayerConnected() and OnPlayerDisconnected() are part of the old networking API and not UNET what is currently being used. In ...
Uri Popov's user avatar
  • 3,027
1 vote

How do I use Unity's TargetRPC calls? Trying to send data from the server to a client

It is probably an issue of timing. The error message is telling you that the object to which the TargetRpcTest script is attached exists on the server, but not on ...
Chaosed0's user avatar
  • 763
1 vote

How do I use Unity's TargetRPC calls? Trying to send data from the server to a client

Based on this code i'm assuming that you want the data to be sent from player to player? ...
Nolic0321's user avatar
1 vote

Creating a master server for Unity game (Unity 2017)

Reality check.The Unity CCU deal is fine for novice developers. Assuming your game will be the next blockbuster game is going to be disappointing. Spending 100's/1000s of hours setting up a cutting ...
Jack Spite's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible