Hot answers tagged

7

TL;DR: You can't do it natively in Unity Microphone.Start returns an AudioClip which has 3 load types, none of which fit your use case. All of them (even the .Streaming one) require the entire clip to be on the users computer already. Using AudioClip.GetData() and sending a file over the network (in Unity, using Networking.NetworkTransport.Send()) would be ...


1

Didn't really solve this particular problem, but found a much nicer working workaround. Created a Dummy prefab with my vehicle's netcode attached to it(Note, I separated vehicle physics code and vehicle input netcode, left physics code on vehicle object where it belongs). Saved this dummy as an asset, added NetworkIdentity component to it and added it into ...


1

While asking for what technology to use is off-topic here... I can tell you what not to use. First of all, you want the game instances to be able to work as clients or servers. There will not be an stablished server to which everybody connects. That is, you want a peer-to-peer network architecture. Please note that while we are talking P2P, that does not ...


1

I solved my problem with another way that works very well. For checking the port is free or not we can use System.Net. and before Network Manager StartServer(), we have to check the current port is busy or not. int the_port = 7777; IPEndPoint[] list_all_ports = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()....


1

When using a SyncVar, a network change can be triggered by adding a custom Editor with a field of the same type. This editor can then set the syncvar property to match the editor value when it change, which lets network updates trigger as normal.


1

If your intent is to create a basic multiplayer networked game, I raccomend following this tutorial series In the past, I had the same problem with some of my variables that I was not synchronizing. Try to add the [SyncVar] attribute to your animSpeed variable in order to synchronize it correctly. You should also test the animation speed in a new empty ...


1

On UNET, when you Instantiate and Destroy Objects (or deactivate, if such the case), you must make use of Spawn and Unspawn respectively, so those objects appear / dissapear on the other clients. You still need to make use of Instantiate and Destroy, but you must add hat extra step. The given examples are from a tiny UNET test I've made: [Command] private ...


1

as long as you are inheriting a network behavior you can run a check if (isLocalPlayer) add to list. Or you can override the OnStartLocalPlayer () public override void OnStartLocalPlayer() { //Add To Player List }


1

try with a RPC call [Command] are message from a client to the server a [ClientRPC] are messages that are send to all the clients from server so in order to show all your clients the towers use a rpc call void Start() { RpcSpawnTowers(); } [ClientRpc] void RpcSpawnTowers() { for (int i = 0; i < midTowerSpawns.Length; i++) { GameObject ...


1

Fixed it on my own. Sometimes walking away from the computer for a minute can really help. Here is what I was doing wrong in case anyone is interested for future reference. The server was spawning the object correctly, but I was never sending a reference of the object back to the client. I did so by changing my function slightly and adding a new Rpc. [...


1

In your code you call the Command if you are the server, and call the RpcCall if you are not the server. It works the other way around: Commands are issued from the client to the server. RpcCalls are called from the server to all clients. So if you are the server, you should call the RpcCall. And if you are the client, you should send a command to the ...


1

Firstly, OnServerAddPlayer only runs on a server, so the clients don't run this code. Secondly, combined with the fact that the properties of child objects are not transmitted with a NetworkBehaviour, so the change to set the material color will not be sent to clients. So you need a client-side hook to leverage when an item is added to the scene; you should ...


1

Try this. It compares time alive on different instances of the class, ensuring that your first instance will be the one that survives. public class ExampleClass : MonoBehaviour { float time = 0; void Awake () { DontDestroyOnLoad(this); } void Update () { time += Time.deltaTime; } private void OnLevelWasLoaded(int ...


1

OnPlayerConnected() and OnPlayerDisconnected() are part of the old networking API and not UNET what is currently being used. In order to achieve what you want you have to exted the Network Manager. Something like this will get you on the right track : using UnityEngine.Networking; using UnityEngine; public class Send_data : NetworkManager { public ...


1

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 the client. On the frame upon which the connection is established, Unity has not yet spawned all the objects on the clientside, since it needs to send messages over the network to do that. Just to ...


1

Based on this code i'm assuming that you want the data to be sent from player to player? // If we're not the server, we don't have any business in sending data to players. if (!isServer) { return; } Which isn't the correct use of [TargetRpc]. If you look at the Unity documentation it says This is an attribute that can be put on ...


1

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 edge personal 'free' server only to have 1 or 2 players visiting daily would be soul destroying. Instead, concentrate on time-to-market and build up your player ...


1

You can have as many users as you would like and scale as you grow using unity multi player services as seen here UnityMultiplayer Unity offers a free amount of Concurrent users (CCU) for each license. Personal: 20 Concurrent Users Plus: 50 Concurrent Users Professional: 200 Concurrent Users If you need to increase the number of CCUs that your game ...


1

The reason of the error is that you didn't stop previous host and trying the adding new. With the same credential you are trying to add same server. So first stop host then, add host.


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