5

As per the documentation, [Command] and [ClientRpc] should be in a NetworkBehaviour, not in a MonoBehaviour. NetworkBehaviour's must be spawned using NetworkServer.Spawn(). Moreover you should use a NetworkClient Object to connect to the Server. Take a look at this Note: As of Unity 5.1 offline documentation is not up to date. Even some aspects of online ...


5

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 state. It does this by taking all of the game logic and running it instead of the clients* and then sending updates as it sees fit. The most basic building blocks ...


4

[SyncVar] only sends messages from the server to the client. You need [Command].


4

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 mean you have to create a SQL database. Some games use services that provide a nice interface for NoSQL databases (for example MongoDB via GameSparks or ...


3

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 simple but it is what I needed. Hopefully this helps.


2

It seems i misread the docs for [Command], the objects are now instantiated on both clients // Update is called once per frame void Update() { if (isLocalPlayer) { this.transform.Translate(new Vector3(Input.GetAxis("Horizontal") * speed * Time.deltaTime, Input.GetAxis("Vertical") * speed * Time.deltaTime, 0.0f)); if (Input....


2

SyncRigidBody2D will also update velocity and angular velocity (if syncSpin is set to true). It will not however, also sync the entire state of the physics simulation, just of the synced body. One way to reduce pulsing would be to use curved interpolation to match the start and end velocities, however it seems Unity's NetworkTransform script does a linear ...


2

Unity's Asset Bundles were designed specifically for this purpose, to allow you to add/download new Unity content and prefabs without the user having to update their game client at all. http://docs.unity3d.com/Manual/AssetBundlesIntro.html


2

Laszlo Fuleki's answer is fine. The problem is that, if you are asking this, you probably are not using a suited level structure. So if there's an internet connection, check for a new level avaliable and if it proceeds, show it to the user (you can use a system notification or an inbox icon inside the game). Then there are 2 options: The level is already ...


2

Reading more into this area I have come across Client RPC calls covered here ... http://docs.unity3d.com/Manual/UNetActions.html ClientRpc calls are sent from objects on the server to objects on clients. They can be sent from any server object with a NetworkIdentity that has been spawned. Since the server has authority, then there no security issues with ...


2

What you want is NetworkServer.SendToClient or NetworkServer.SendToClientOfPlayer. You'll want to read up on Network Messages, and then check out NetworkServer here.


2

Maybe it is possible, but I don't think that this is supported in the new HLAPI network system. What you could do is have all the componentes in the prefab you instantiate disabled, and enabling them during runtime


2

This turned out to be much easier than I imagined. Don't know if this is a best practice, but you can just attach the sound manager to an empty game object and get a client instance of it via GameObject.Find("Name of your sound manager").GetComponent<SoundManager>(). You can do this inside of public override void OnStartLocalPlayer (). Get rid of the ...


2

Syncing physics simulations can be complex. Where are you doing the collision test? On the server? On both clients? On only the client who shot the bullet? If the collision test is on the client, look at Collision Layers: http://docs.unity3d.com/Manual/LayerBasedCollision.html This would allow you to place the local player on a different layer to remote ...


2

You better use Singleton pattern which ensures that object will exist in in a single copy: public class ExampleClass: MonoBehaviour { public static ExampleClass instance = null; void Start () { if (instance == null) { instance = this; } else if(instance != this){ Destroy(gameObject); } ...


2

[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.


2

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 last shipped with 2018.4 LTS and supported until early 2021. The LLAPI will be last shipped with the 2019.4 LTS and have support until Spring 2022. Therefore, ...


2

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 JavaScript file which defines the functions you need and implements them by calling native browser functionality. Give it the file extension .jslib Put it into ...


1

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 will have camera 1 active, B will have camera 2 active. The rest of the game world is synced between the clients. It will be a lot of work to retrofit your ...


1

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 off the window. But our test program was an external exe (Blaster.exe) which is a console program. So it looked like the messages were arriving and the update ...


1

you can try changing delay value in Network Manager from 0.01 to any higher value. 0.9 worked normally for me.


1

You method makeItRed is a static method which sets a variable which is most likely also declared as static. Static variables share their value between all instances of the class. Call the method on one instance of ColorController and you affect them all. So make opacity, MakeItred and MakeItOff non-static variables and have the raycast hit code (which you ...


1

I had the same problem. Turns out the class that inherits from NetworkDiscovery is not allowed to have it's own Update() function.


1

Take a look at Photon Turnbased instead of Photon Realtime. They have a step by step guide as well. Photon Photon Turnbased offers everything that Realtime has but is geared towards games with less interaction between players (turnbased or not) and games that can be paused and picked up later on (asynchronously). It makes more use of Webhooks (e.g. to ...


1

The [SyncVar] attribute only works on simple data types. You can't synchronize generic objects, or lists/arrays of generic objects. SyncListStruct will allow you to synchronize lists of structs, however. Probably the closest thing you can get to what you want (without writing your on OnSerialize and OnDeserialize methods) is something like this: public ...


1

You'll want to take a different approach for this. Rather than trying to change the players' positions based on who the local player is, move/flip the camera to orient around the local player. Here's one way you could do this: Create a component to attach to your camera: using UnityEngine; using System.Collections; public class PlayerCamera : ...


1

Use a dictionary to keep the entities and requests in them, and a SearchContext to hold the related data for one entity together: class SearchContext { List<Vector3> points; }; public Dictionary<String, SearchContext> context = new Dictionary<String, SearchContext>(); [ClientRpc] void RpcPosFromServerToGoTo(Vector3 [] path, String name)...


1

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 #if UNITY_EDITOR using UnityEditor.Build; using UnityEditor; using System.IO; public class BM_AndroidBuildPrepartion : IPreprocessBuild { public int callbackOrder { get { ...


1

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 their turn, update the other ball with the exact resulting properties of the first. Swap their visibility, rinse, repeat. Also, make sure to turn off all the ...


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