#archived-networking

1 messages · Page 111 of 1

molten condor
#

i tried and my own name is invisible - thank you
i just have to test now if other peoples name are still visible.

#

yes but already got it

mortal horizon
#

👍

molten condor
# mortal horizon 👍

thank you very much worked.
Another question to that topic:
Can i let the game render shadows of a gameobject which is secative(false) ?
I have VR googles in the game and want the shadows to render but the player shoudln not see his self vr googles?

modern drift
#

thats doesn't have to do with networking

high walrus
#

i want to create unity mirror multiplayer game which is server based and it creates room automatically for max 50 players : room creation and player assigning to room is done in server : and game logic also done in server: I want to know where to start and how to do it

dusky storm
high walrus
#

Can you share link to me

sage agate
#

i am using Photon for Multiplayer.
the unity editor cant join Rooms that were created on any build of the game.
basically rooms created with builds of the game isnt visible for the unity editor
anyone know why?
please ping me if anyone responds

dreamy talon
#

How can I ensure that all the requests are not only done before proceeding, but that it didn't send back a "rate-limited" JSON with nulls?

public static IEnumerator GetSpecificCharacterList(JikanCharacterListResult characterList, System.Action<List<JikanSpecificCharacter>> callback)
    {
        List<UnityWebRequestAsyncOperation> requests = new List<UnityWebRequestAsyncOperation>();

        for (var i = 0; i < characterList.characters.Count; i++)
        {
            UnityWebRequest uwr = UnityWebRequest.Get(characterURL + characterList.characters[i].mal_id);
            requests.Add(uwr.SendWebRequest());
        }

        yield return new WaitUntil(() => AllRequestsDone(requests));

        HandleAllRequestsWhenFinished(requests, callback);

        foreach (UnityWebRequestAsyncOperation request in requests)
        {
            request.webRequest.Dispose();
        }
    }
#

Here is the second function:

private static bool AllRequestsDone(List<UnityWebRequestAsyncOperation> requests)
    {
        return requests.TrueForAll(r => r.isDone);
    }
#

Relatively simple, but about halfway through (say 50 requests) the API starts returning null values because it's rate-limited. I would like to restart the request if that's the case.

#

It probably wouldn't be a good idea to retry the entire 50 requests, so maybe I could store the ones that retrieved valid values and then try the ones that didn't work in order

agile spade
#

hey i got mongoDB api working on my unity project by downloading like 20 addon dlls. will this work for clients though?? i know deadfrontier and a few mmos with like 100k players have been made.. but, i have no idea what thier database solutions were.

#

azure/fire base and the mongodb sdk are garbage

#

they are basically local databases..

#

but, the base mongodb is good. but, idk if it'll work outside of developer build.

mortal horizon
molten condor
astral gull
#

May I ask then, how to do this code in a multiplayer way? Possibly server-auth cause the goal is a dedicated server. I understand that there're a lot of things wrong in this code but a general idea of what are the main problems and how to solve them would be really appreciated
https://pastie.io/kxpzbr.cs

modern drift
heady stump
astral gull
heady stump
sage agate
#

Can i use Playfab for A Project with Photon PUN ?
Cause i dont see PUN in the Playfab addons place, there appears to be only Photon Realtime and Photon Chat

dreamy talon
late swallow
#

hello

#

I wanna know how to save some items and making it work with multiplayer

#

I'm using Mirror

#

and I want the Equipping, Unequipping and Dropping to be commands so they show up in the server

#

but I want the saving to be done locally

#

on the client

#

I have a pick up script that gives the item to an inventory holder, in the inventory holder a function gets called to updated an instance of an inventory and to update the ui

#

the UI updating needs to be on the client only I guess

weak plinth
#

how do i join a random room in unity HLAPI with custom button (if there is no rooms available then create and wait for other players ) ?

modern drift
late swallow
#

I know, but it's fine for this project

#

It's mkre singleplayer / friends based

modern drift
late swallow
#

But I have a lot of functions like equipping, unequipping, dropping

#

It's past 1 am rn so I can't work lmfao-

modern drift
late swallow
#

It's a bit more complicated

modern drift
#

seems good for your use case imo

late swallow
#

Can we talk tomorrow?

modern drift
#

uh sure

late swallow
#

Yeah

modern drift
#

gn

late swallow
#

It's- 1 am lol

#

Yeah!

#

Gn!

modern drift
#

same here

#

im on the bus LOL

late swallow
#

Lol

#

LMAO

#

Nice

#

I'll dm you

modern drift
#

sure np

heady stump
#

It's a date! PepoBeerCheer

agile spade
#

What the best method for this? (Mmorpg) balance of speed and security?

#

Maybe the struct?? I can make a limit of one.

#

Maybe 2 and 1? That way the client can read more easily through a gui when the skill will finish but have the actual change handled by a struct list that only the server side can see?

vital yoke
high night
#

@vital yoke I think your objects need to have the networking component

#

Network identity I think?

#

I think that was the components name

#

You are using an outdated networking solution though

vital yoke
modest current
#

Hey, i was testing my invisibility feature and when i call my function(Code below) it ends the conection to the server but it doesnt give me any errors?
https://pastie.io/raw/hjmseg

#

(i use mirror btw)

#

oh and it only does it when another player is on the server

odd flower
#

how can in sync objects?

terse crow
safe sand
#

does someone tryed MLAPI?

#

is MLAPI supports kinda rooms?

#

when one player host many games

strong axle
#

Using photon pun and running one game in unity editor and one through the exported build, the public float hp value for th player doesnt seem to be updating from client to client eg
client 1 hits client 2 and on client1 side it says client2's hp is 0 but on client 2 it says its still full
both of them have photon view & photon transform view classic

spring crane
#

Photon view or transform have specific roles and won't sync that automagically. You need to use one of the communication methods of PUN to sync additional stuff, like RPCs. Check the docs for more.

high walrus
#

i want to create room based server game on unity mirror multiplayer: how can i create new room in server when maxNumOfPlayer reach in a room and remove room when game on that room is complete

stiff ridge
mint tusk
#

hey dose anyone khow mirror networking i need help

olive vessel
#

Don't ask to ask, just ask

sacred oak
#

Hello everyone, I'm having some trouble with networking, can anyone help me out?

The issue is that I can't manage to send a request to my Node backend server, no matter what. When I request the server from Insomnia/Postman, it works fine. But when I do it from Unity, the server doesn't even register the request.

Additionally, it seems that the problem is specific to my internal network, since I'm able to send the same request to an external URL and it works fine.

I've already digged around the firewall rules, but the error remains even with the firewall off.

Any clues?

sacred oak
#

if anyone comes across this: the problem was with my WSL instance that wasn't forwarding properly, when running the server directly on windows everything runs great

tender moth
#

Hi, can someone explain me shortly, how server authoritative movement works in general?
Does the client send the input to the server, the server handles the playerstate and send it back to the client?
How to handle high ping, etc.?

heady stump
#

The client says which way it wants to go, the server calculates the movement and updates it for everyone, including the client who wanted to move

#

So basically, move forward, left, right, back, jump is commands the client can do

tender moth
#

Does the client have to send the delta-time to the server, too?

heady stump
#

Hm, why?

tender moth
#

doesn't have the server to know how far the client moves in one frame, or do the client send the input in a fixed rate?

heady stump
#

You cant trust a client with any kind of calculation

#

If you care about cheating that is

tender moth
#

ok

heady stump
#

So the client says move forward, and then the server calculates how far the player goes each frame

tender moth
#

ok, but client-frame != server-frame. So how do you synchronize this?

heady stump
#

Hm, I see what ur saying, I dont know if they need to be synced?

#

Atleast in my solution, the client only sends commands and looks what the server gives back

tender moth
#

ok

#

well the i will try it that way 😉

heady stump
#

Good luck!

tender moth
#

thx for your help 😉

#

another question: What if the server runs with (lets say) 30fps, and the client send more then one Input-packet between two frames. Does the server ignore the old one?

heady stump
#

I dont think so, once a movement packet comes to the server, it calculates the new position and sends back the position to all players

#

But, you might not get that update until the next frame happens in the server

tender moth
#

ok

#

so if the server has 2 movement-packets in the queue on the update loop, it calculates both movements?

indigo thicket
#

Hey guys, I'm using MLAPI, I was wondering if there are ways to create RPCs with bool values

#

I need to add an item to a player inventory using a client RPC, and if the player has the inventory full the RPC function should fail, but I can't create an RPC that's not a void type

heady stump
#

I'm not experienced with MLAPI, but I'm quite sure you can convert a bool into bytes and send it that way

indigo thicket
#

No, I mean

#

the RPC must return a bool type

gray pond
gray pond
gray pond
weak plinth
#

Hi, I'm new to unity but was wondering if photon would be well suited to a mobile turn based multiplayer game? I was looking at ue4 but it seems more geared towards instanced realtime shooter game sessions

haughty heart
wind citrus
#

Hey, when i export my game to webgl and connect (host is a normal pc build), it blackscreens (i see the player spawned in on the pc build). Ive made a simple ui with a connect button which loads just fine in webgl, it only happens when i press connect.

#

this is the error i get: host id out of bound id {254} max id should be greater than 0 and less than {1}

#

Any ideas what could cause the error?

silk helm
#

Hey guys, I'm trying to do this but with JoinRandomRoom

#

Is it possible to do so?

#

Im trying to use PhotonNetwork.ReconnectAndRejoin();

swift epoch
#

Is it possible to have multiple games using Mirror running at a time?

mint tusk
#

how do i setup random spawn points mirror?

swift epoch
olive vessel
#

You can't use the same port for many different servers

modern drift
mortal horizon
indigo thicket
#

Hey guys how can I access a player prefab with a clientId in MLAPI? (Serverside)

mint tusk
#

@modern drift Thanks

thin sapphire
#

can any one tell the example of local multiplayer for android ?? which works in above 2020 unity

olive vessel
#

Netcode for GameObjects and Mirror can both do that AFAIK

weak plinth
#

Which is Unity's latest multiplayer server ?

weak plinth
#

guys, I’m really stuck. I’m setting the player’s skin custom properties though Photon and only the local player’s skin changes - the others doesn’t?

Does anyone know why this is happening?

p.s: don’t gimme a “look on Google answer” please, that’s not gonna help since I already tried :)

swift epoch
#

I'm using ParrelSync and Mirror, and I keep getting this error. I've removed and re-made the clone multiple times with no difference, and I've removed and re-made the Network Manager object, as well as restarted the editor

gray pond
swift epoch
#

That worked! Thanks!

ashen ether
#

Hey guys. Quick question, does adding multiplayer (in general not just unity) impact player fps? I'm only curious as I have zero experience in multiplayer

#

To be clear im not talking about increased players, more entities, etc.

agile spade
#

hey, i am making a public void OnAfterDeserialize() { ClientPassContructionValues(); //Dispose //throw new NotImplementedException(); } for my scriptable object constructor on a multiplayer game. is there a different/better way to make a scriptable object from json values using private variables on the unity object? or, maybe even not as long as it's secure and not prone to exploits.

#

im loading / saving to my database just fine

#

but, its all in json atm. and i have scriptable objects for the clien. so they can read the update times etc

#

but, i wanna offload my server a bit

#

and make as much of this client side as physically ossible without making it insecure.

#

is there a video or a resource that goes into this?

#

the only 2 games that are mmos that used unity I know of are albion online and dead frontier but, in both of their interviews on gamemaking.biz they say they black boxed unity eventually and used their own dll plugins.. Is there anyway to use scriptables in a scope for an mmorpg? @viral widget cause you look helpful.

#

basically, cause of memory leaking people can theoretically change values.

#

and i do grab resource information for upgrading and saving.

#

and i dont wanna load from the database everytime i do this, its take 1 minute+ after a few thousand players to do this

#

so its much faster to keep a list, however, this is going to add a lottttt of ram up on a server if it needs to keep 1 mb od data for every player +1million

#

so, its not practicle.

weak plinth
#

Is there any way to create networking for free (without payed 3rd party software) or is Steamworks (Steam) capable of handling the whole multiplayer thing itself?

modern drift
heady stump
#

There are great tutorials on youtube for this

weak plinth
#

@heady stump Is Unity Relay or Unity Lobby a good solution? Just read about it on the website that these 2 options are currently in Beta?

heady stump
#

I dont know anything about those, sorry.

weak plinth
#

Okay. Thank you though 🙂

agile spade
warm lodge
#

Has anyone here used PUN for MMO open-world based games?

granite yew
#

how do I sync lists easily in Photon unity networking?

prime salmon
#

I'm getting these kind of errors with the new Netcode release:

#
OverflowException: Reading past the end of the buffer
Unity.Netcode.Components.NetworkAnimator.ReadParameters (Unity.Netcode.FastBufferReader reader, System.Boolean autoSend) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.2/Components/NetworkAnimator.cs:396)
Unity.Netcode.Components.NetworkAnimator.SendAnimStateClientRpc (Unity.Netcode.Components.NetworkAnimator+AnimationMessage animSnapshot, Unity.Netcode.ClientRpcParams clientRpcParams) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.2/Components/NetworkAnimator.cs:427)
Unity.Netcode.Components.NetworkAnimator.SendAnimStateClientRpc__nhandler (Unity.Netcode.NetworkBehaviour target, Unity.Netcode.FastBufferReader reader, Unity.Netcode.__RpcParams rpcParams) (at <c9cf9d45b44c4ede894402c60534568f>:0)
Unity.Netcode.RpcMessage.Handle (Unity.Netcode.FastBufferReader reader, Unity.Netcode.NetworkContext& context, Unity.Netcode.NetworkManager networkManager, System.UInt64 senderId, System.Boolean canDefer) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.2/Runtime/Messaging/Messages/RpcMessage.cs:93)
Unity.Netcode.NetworkBehaviour.__sendClientRpc (Unity.Netcode.FastBufferWriter writer, System.UInt32 rpcMethodId, Unity.Netcode.ClientRpcParams rpcParams, Unity.Netcode.RpcDelivery delivery) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.2/Runtime/Core/NetworkBehaviour.cs:193)
Unity.Netcode.Components.NetworkAnimator.SendAnimStateClientRpc (Unity.Netcode.Components.NetworkAnimator+AnimationMessage animSnapshot, Unity.Netcode.ClientRpcParams clientRpcParams) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.2/Components/NetworkAnimator.cs:415)
Unity.Netcode.Components.NetworkAnimator.FixedUpdate () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.2/Components/NetworkAnimator.cs:228)
#

anyone knows what's going on here?

jagged violet
#

Is MLAPI good to start with?

#

I want to make a soccer game where players and balls are rigidbodies

#

The problem is that from client view pushing ball is laggy and awkward. I know that to synchronize movement we need to use NetworkTransform but when I use rigidbody.AddForce it seems it breaks it at all.

olive vessel
#

If you use Netcode for GameObjects' latest release (That's the new name for MLAPI) it has NetworkRigidbody

late swallow
#

hello

#

so I have this item object I can equip

#

I grant it authority

#

it returns true when I check it in the update function

#

but when I call any networking function, it just gives me a null reference error

#

it doesn't start the function itself

#

it's not that the function has something missing

#

this is how I'm granting it authority:

#
NetworkServer.Spawn(itemToEquipObject, connectionToClient);```
#

this is all done in a Command function

#

debugging it returns connection(0) which I'm fairly certain is good-

weak plinth
#

Yesterday it let me load image urls to Unity, but today I get this error. Any solution?

shut yarrow
#

It means the server you try to access is unavailable

#

If it's not your server you can only wait till it gets back

wind carbon
#

I'm not sure if I remember this right but when using UNet I remember that you could set local authority on a player and that made it possibly for a client to move their own Transform thus synchronising it on the server (Client authority). I can not find that alternative in the new NetCode?

https://docs.unity3d.com/Manual/UNetAuthority.html (Local Player Authority checkbox)

#

This is what my LocalPlayer NetworkObject looks like on the client.

jolly wadi
heady stump
#

Using a self built tcp/udp network layer, do you need to verify which client is whom by a token or something similar after the handshake is complete?

shut yarrow
#

I do that with each UDP packet I receive, if there's no identifier or a wrong one then the connection will be closed

heady stump
shut yarrow
#

I don't necessarily enclose a client ID with each packet, but a token of some sort definitely

heady stump
#

Alright thank you!

shut yarrow
#

That way I can at least be more or less sure they aren't spoofing packets and pretending to be someone else

heady stump
#

Yea, you can always bruteforce I suppose

shut yarrow
#

The tokens don't even need to be that unique either, as long as nobody knows tokens of other users it's good enough imo

#

I use a 4 byte token, but I could've used a 2 byte one as well and it would still probably be sufficient for what I need it for

#

2 bytes is still about 65k possible tokens so nobody is going to brute force guess that without getting noticed

heady stump
#

Right

#

Do you know if there's a need for a token in TCP as well?

shut yarrow
#

In my case I just disconnect them instantly if the token is missing or incorrect

#

For as far I know (I could be wrong) it's not needed because TCP actually has handshaking built in

#

UDP is connectionless, which means just send a packet and forget, there in essence is no real connection and no handshaking

heady stump
#

Yea

#

Alright ill add a token for my UDP packets and do some research into TCP

shut yarrow
#

Do you use TCP for reliable transmission?

heady stump
#

Yea

#

UDP for movement and TCP for moving items and so on

shut yarrow
#

I thought so, maybe consider looking into something like ENet which is what I use

#

It can send reliable over UDP

heady stump
#

ENet is some Unity thing?

shut yarrow
#

It definitely beats having to use 2 protocols which has its own problems

#

It works with Unity let me put it like that

#

I take it that you did your own networking from scratch?

heady stump
#

Yea

shut yarrow
#

In that case you don't have much to lose with ENet I think

#

Because it does all important stuff already for you and it is very simple to get going, you just build on top of the base that it gives you

heady stump
#

Alright, ill check that out as well then, but I still need to add tokens in the packets, right?

shut yarrow
#

I recommend that over doing it from scratch because it's a solid library which allows you to do everything on UDP

#

Yes you still need that

heady stump
#

Ah its only UDP, gotcha

shut yarrow
#

You can look at the example there on how it works, it doesn't get much simpler than that. I recommend this to anyone who doesn't mind working from a low level point of view but still want to get going quickly

heady stump
#

Cool, I mean, I have everything already working, I just started thinking about security

shut yarrow
#

Yeah that's a thing you definitely need to address

#

Also doing checksums for data integrity

#

Quite sure ENet can do that as well but I've done my own and it works really well so far

heady stump
#

I'll be honest, I dont even know what that means 😄

shut yarrow
#

Ok I'll try to explain in a few words

#

Whenever you send data over the internet, it may lose some bits or some bits get flipped which makes your data corrupt. A checksum can help to check for whenever this has happened. From a high level point of view you calculate a sum of the data, which gives you a number. You send this number with the packet, and when you receive the data, you compute the checksum again and check if it matches the checksum that came with the packet. If these 2 numbers match, the data can be considered unchanged

#

If the 2 numbers don't match, you drop the data cause it has been changed due to one of many different causes

heady stump
#

Oh, so the sender sends a checksum in the packet so that the reciever can doublecheck the data?

shut yarrow
#

Yes

#

You compute the checksum and attach it with the packet data

heady stump
#

And that is both ways, client -> server and server -> client?

shut yarrow
#

Yes both ways

heady stump
#

Ah cool, what if that checksum is corrupt tho? U just ignore the packet i suppose

shut yarrow
#

I do this with any packet, and for sake of simplicity the first 2 bytes of my data is always the checksum

#

Yeah if after computing the outcome doesn't match the supplied checksum you just ignore the packet

heady stump
#

Great, got it

shut yarrow
#

There are established ways of doing this though, so if you're going to look at this, try find some working implementation on github for example and play with it for a bit to make sure it does what you expect it to do

heady stump
#

Would you mind sharing how you calculate your checksums or is that too much to ask after all this explaining? 😉

shut yarrow
#

I haven't written everything myself I take shortcuts where possible

#

I can send you the code I use in a DM

heady stump
#

Appriciate it!

late swallow
#

The object has authority

#

But I can't call the functions

harsh imp
#

K guys, i have no idea about networking.
But still have a question.
Is it possible to make some sort of connections trough IP address like in Minecraft, Terraria, Cube World without buying server for that

#

If its possible i would like to read something about it

swift epoch
#

Is the ordering of my base.Whatever()s compared with the other code in the function correct?

For functions that create something I should run the original first then run my own code, and for functions that destroy something I should run my own code first, correct?

I'm using Mirror, but I don't know if that really matters for this question

austere yacht
#

If it isn’t I’d put my code after base on anything but disable/disconnect/destroy/etc.

swift epoch
#

Ok, thank you

weak plinth
shut yarrow
#

The server URL is inside that MediaUrl, not sure where you got this code from but it leads me to believe you are not very familiar with the codebase you're working with

weak plinth
shut yarrow
#

Like I said before the server is unavailable. This could be because of many reasons. If you don't own the server then you're out of luck

#

Some servers also disallow GET requests from applications that aren't web browsers. I don't think this is the cause of your problem because you'd probably get a different error unless they just dish out a 503 in general if they don't want to respond to the request. Either way, if you don't own the server that you're doing a request from then you have zero control when something goes wrong and it just breaks the functionality of your application/game

#

So time to rethink whatever you're trying to do

orchid inlet
#

Hello everyone! I'm trying to authorize Firebase using Facebook.

For several days now I have not been able to solve this problem. One and the same error constantly takes off. I've already tried a bunch of methods from google, but nothing helps, so I think whatever you suggest is something I've already tried.

Simple Facebook Authorization is working. Simple Firebase Authorization via Email/Password is working. But together this guys dont wanna work

The last thing I hope for is that the problem is in my code. Because auth.CurrentUser == null. It seems to me that there is something with asynchronous here.

There is my script https://pastebin.com/iTh7mPRX

Help Please.

oak flower
#

@orchid inlet Don't cross-post, pick single relevant channel next time.

orchid inlet
oak flower
weak plinth
#

Hi! I want to create a game with in-game mail in it. Which I want to send gifts for clients from server to game I'd (id created by Google, Facebook,twit,etc..) to a specific player in mirror. How do I make it Can some one help me?

sly leaf
#

Does Netcode for GameObjects support dedicated server?

weak plinth
#

Does anyone know an imgur, but for audio files?

#

I just wanna download .mp3 files with unitywebrequest

spark glen
#

Does anyone know the difference between mirror and steamworks

austere yacht
jolly wadi
#

it implements both mirror and steamworks

spark glen
swift epoch
#
public override void OnClientConnect(NetworkConnection conn)
    {
        base.OnClientConnect(conn);

        NetworkClient.localPlayer.name = "Local Player";
        Debug.Log("Connected");
    }

I'm using Mirror, and have this in a custom NetworkManager. It seems to work fine on the host player, but just produces

System.NullReferenceException: Object reference not set to an instance of an object
  at ArenaManager.OnClientConnect (Mirror.NetworkConnection conn) [0x00007] in D:\Github\Artifacts-of-Punishment\Artifacts of Punishment_clone_0\Assets\Scripts\Networking\ArenaManager.cs:17 

on the client. Line 17 is the one that sets the name. I believe localPlayer is null. Any ideas to fix that?

heady stump
swift epoch
#

I get the same error with Debug.Log(NetworkClient.localPlayer.name);

#

And I just tested Debug.Log(NetworkClient.localPlayer);. I got Null

heady stump
#

Alright, wish I knew more about Mirror to be able to help, afraid I dont, good luck :p

swift epoch
#

Thanks for offering what you could

mortal horizon
swift epoch
#

Yep, that fixed it! Thanks

cloud orbit
#

Hey guys, can anyone explain what the point of Unity.Networking.Transport is? What does it provide over c#'s networking api?

#

I've been looking for an explanation online but there doesn't seem to be much beyond Unity's own documentation

#

I wrote a networking solution for my game a long time ago but it's a bit messy. I want to write a more robust version that I could easily extend with support for peer-2-peer networking, server authoritative networking, steamworks, or whatever else I feel like adopting down the line.

torn lance
#

You might want to look into lidgren, it's kind of a midway between straight up socket programming and Mirror. Gives a good amount of control over what data you're sending and doesn't abstract away too much.

#

It is a bit hard to find resources though, admittedly

cloud orbit
#

Thanks! I'll look it up right now

#

Yeah most people don't seem keen on building all of this themselves and would rather use mirror or some other solution instead

#

I don't need all of the high level stuff that those systems provide though. Just reliable message passing.

#

It doesn't even have to be that fast

torn lance
#

Sockets are a major pain that's why lol, tho I'm not a fan of mirror either

austere yacht
torn lance
#

Lidgren basically takes care of the handshake + sending messages on different channels (Reliable Ordered, Unreliable Ordered, Unreliable)

#

And then you can define the bytes in the actual message if you'd like

#

Oh that's what a transport layer is...

austere yacht
#

transport gets you talking but nothing else

torn lance
#

You learn something new every day, finally I know what to google!

austere yacht
#

No validation, no auth., no rpc, no network variables, no portals, no manager….

#

if you use netcode for game objects (ex MLAPI) you get some abstraction (rpc, basic network variables), with mirror you get high level abstraction and ready to use components

cloud orbit
#

Okay okay so it's a net benefit over c#'s networking layer I guess

austere yacht
#

that’s got nothing to do with c# other than that it is written in c#

cloud orbit
#

Although I was already using tcp before so maybe it wouldn't provide that much in my case

austere yacht
#

tcp is just a protocol

cloud orbit
#

I mean vs just using c# listeners and sockets directly

#

Well it has built in reliability no?

austere yacht
#

Yes, and a lot of waste

cloud orbit
#

Yeah but it's turn-based strategy so speed really isn't a concern

#

Still though I'll take improvements if they're free

austere yacht
#

TCP is protocol level reliability, enet & co. Are built on udp and have custom/configurable reliability

austere yacht
cloud orbit
#

Lol for a second you had me wondering what that would provide 😂

merry breach
#

Not sure where else to put this, this seemed to be the best channel for this:

#

So recently, my hard drive died, and I've had trouble pulling up the collab project I'm a part of on the hub ever since, and Unity is not giving me an option to refresh even though my other team members can pull it up just fine. How do I fix this? Thanks!

modern drift
#

like is it on the unity collab thingy?

weak plinth
#

Hello.

I have a Unity project that uses MySQL and PHP.

I need to print Date from server in the Canvas.

so I've made this:

#

And this is what it prints in-game.

#

it should print "Hello today is 2021-10-30 13:03:15"

olive vessel
#

If you can print it in the console, why don't you use the same method to print it to the text box?

weak plinth
#

line 36?

olive vessel
#

On line 33 you can print exactly what you want just fine

#

Then on line 36, you do some weird Get again, which you then ToString?

#

I don't quite understand why you changed how you try and get the text you want, when you literally Debug it exactly as you want it?

weak plinth
#

thank you so much, yes. I did not know "downloadhandler" was the output lol

#

now it works, thank you

old geyser
#

I’m interested in getting into game networking, but I don’t know where to start. Should I just create my own TCP sever and client, or do I use some framework? Also any recommendations for blog posts on tutorials for game networking (specifically ecs related since I’m trying to get into that).

heady stump
# old geyser I’m interested in getting into game networking, but I don’t know where to start....

I really recommend this tutorial by Tom Wieland. It's a very basic TCP/UDP setup for a dedicated server with clients. It's basic because there's a lot missing for it to be used in a production environment, but you can play around with it and learn a lot about low level networking, I certainly did 🙂

https://www.youtube.com/watch?v=uh8XaC0Y5MA&list=PLXkn83W0QkfnqsK8I0RAz5AbUxfg3bOQ5&ab_channel=TomWeiland

In this first part of my C# networking tutorial series, we set up a TCP connection between a dedicated server and a Unity client.
If you get stuck or have questions, ask them on my Discord server: https://tomweiland.net/discord

Kevin Kaymak's channel: https://www.youtube.com/channel/UCThwyD-sY4PwFm7EM89shhQ
List of commonly used ports: https://...

▶ Play video
south palm
#

i'm trying to do networking with mirror, but the NetworkTransform doesn't seem to be updating

#

the other player appears when they join the server
but they're frozen in place
that sphere is the spawn point
and the other player doesn't fall because I have

#
        if (!isLocalPlayer)
        {
            return;
        }```
#

in update
so my gravity code only runs clientside
but that clearly means that the transforms aren't updating across the server

#

and moving both clients doesn't change the position of the other one

#

i've got these settings on the player prefab

unreal sentinel
#

Whats the best package or method to run two instances of the editor at the same time for testing multiplayer functionality

#

I've seen different competing solutions, from project cloners to editors scripts

spring crane
#

Assuming the networking solution doesn't natively support that, using ParrelSync to clone the project for 2 editor instances is the way to go.

unreal sentinel
#

ParrelSync was one of the options I saw, you recomend it?

jagged violet
#

I switched from MLAPI to Netcode for GameObjects and I have a problem with moving player by client. When maps spawns client can't move his GameObject but he is able to see what host does and host can move the client by pushing him. I'm using rigidbody to move the players but the problem is that only host is able to move, client is not.

#

I use NetworkRigidbody to sync properly movement on both players. By debugging i know that input from client is known but it doesn't seem to react by move.

late swallow
#

hello

#

can someone help me with authority?

#

I have these items I wanna spawn

#

after instantiating, I use the NetworkServer.Spawn method and give them authority to the client

#

it works, if I debug it it returns connection(0) which I'm 99% is correct

#

but I cannot send any network function

#

like commands, rpcs etc.

#

it returns a null reference error

#

and doesn't even start the function

#

now that I think about it, it might have something to do with the assemblies

#

but again

#

I have no idea

#

nvm

#

it's not that

#

it's giving me a lot of errors about not having references in the networkbehaviour script

#

the entire script is just

#

returning errors for some reason-

#

I can't use isLocalPlayer, I have to use GetComponent<NetworkIdentity>().isLocalPlayer

#

why don't they work-

#

wtf-

fickle geode
#

Wall of text incoming:
I've been implementing my (very first) from scratch UDP multiplayer and it's been working pretty "OK". I've done the following things, maybe somebody has some tips for what I missed?

  • The game is physics based
  • One client "starts the game" as a host/server. The server listens for incoming UDP traffic. (peer to peer model)
  • Client B, C, D connect to the server. The server adds the new player to the game and sends a packet to each already connected client to add the player.
  • The clients receive a "keyframe" for each player containing all the needed positional data, body data, hp, etc. every 0.5 secs (but in theory this is redundant because the real time packets like the input and damage packets should keep the players in sync)
  • Each client runs the physics simulation on their own. But any damage received is set to 0/zero because the server is authoritative on that.
  • When a player receives damage, a packet is broadcasted (send to each connection one by one by the server) informing the client to update the hp to the same as the server.
  • Clients send their inputs every time/frame that it is not the same as the last one. When the server receives the new input it applies it to the game and broadcast the new input to the other clients. If no (new) input packet was received the other clients and server assume it should repeat the same input as the last packet
  • A "just in case" input packet is send every 0.5s to account for any missed/dropped input packets
  • The server is listening to the socket async, adds the received packets to a queue and the server then processes all the received packets in the FixedUpdate() (main thread).
  • All the packets send by the server to the clients are buffered for one FixedUpdate() and grouped until they reach a maximum size (currently 1200 bytes to fit most MTU). While using wireshark I can see that they are indeed grouped together.
    (continued...)
#
  • All client packets are being synchronous (blocking) send as far as I understand UDP sending is not really blocking anyway on this scale.
  • I've optimized packet sizes by only using the bare minimum of information, and using the least bytes possible for each datatype
  • For example compressing a float -1 to +1 into a "low precision" single byte
  • With one client connected the in+out/server+client packets are ~260 bytes/s with an average length of 73 bytes and 5 packets per second. I really have zero frame of reference wether this is good or bad, any insights are appreciated.
  • One issue that I suspect is that there is no lag prediction other than the client running physics himself. In the scenario that he receives a keyframe with positional data that is "old" (lets say 500ms) all the players will get teleported 500ms behind the current server state. The next keyframe is then received in 10ms and yanks everybody back to the server state, this can ofcourse repeat multiple times in a row and makes for a stuttery experience. I have been reading about the server having a (500ms or so) buffer essencially being behind but I can not really see how that would work with my current client as a server model. I could maybe try to sync the frame number when connecting and adding the frame number to each keyframe. Then if a player receives a very "old" keyframe they could just ignore it or extrapolate from there? I'm not sure how to do that, should I run FixedUpdate for the N-number of frames that the keyframe/packet is old?

Possible TODOs, which will make a big impact?:

  • Use compression on packet data?
  • NAT punching (currently the game needs to have the ports forwarded on the router)
  • ACK for critical packets (there are very little critical packets that are not repeated at least every 0.5s)
  • Ensuring ordering packets (avoiding out of order inputs, repeating the last, incorrect one, although almost always corrected within 0.5s)
sly leaf
#

Do you guys know any free or cheap website I can test my headless Unity server on?

low vortex
#

Hello everyone,
I'm currently trying to wrap my head around networking. I would like to to create an RTS with deterministic lock-step.

So I imagine that primarily all I really need is client-hosted servers (I don't want to deal with NAT if possible).
The clients (including the host) would send their commands such as 'order this unit to a certain location' to the server.
The server would then gather all these messages up and send them back to the clients on the next game logic tick.
Of course this could be complicated further to improve the player experience but this is the base principle everything would be built upon.

Any suggestions what library I could build this logic ontop of? Is it possible to implement such a thing with Mirror?
Would Mirror Network Messages be a good fit for this?

late swallow
#

I have a question about how I should code in multiplayer

#

I am using mirror and here is how my inventory script works:

#

I have these commands

#

Interact, Add/Remove Items, Equip/Drop Items

#

in add and remove it's pretty simple

#

the server adds the items to the clients which is saved locally (it's fine for this project)

#

but for equipping and dropping it's like this

#
    public void CmdDropItem(ItemSlot itemSlotToDrop)
    {
        if (itemSlotToDrop.itemId == equippedItem.itemId)
        {
            equippedItem.amount--;
            
            if (equippedItem.amount < 1)
            {
                NetworkServer.Destroy(equippedItemObject);
                equippedItem = null;
            }
        }
        
        Rigidbody groundItem =
            Instantiate(GameManager.instance.groundItemPrefab, itemHoldPoint.position, itemHoldPoint.rotation)
                .GetComponent<Rigidbody>();
        NetworkServer.Spawn(groundItem.gameObject);
        
        ItemSlot itemSlot = new ItemSlot(itemSlotToDrop.itemId, 1, itemSlotToDrop.regionName);

        groundItem.GetComponent<ItemHolder>().SetItemSlot(itemSlot);
        
        groundItem.AddForce(itemHoldPoint.forward * 50);
        
        RemoveItem(itemSlot);
    }```
#

and this is for dropping

#

should I make the server update a certain item on the player

#

like

#

an int let's say, that holds the id of the item

#

and have clients subscribe to an event and update the graphics on their clients?

#

I just want to know how I should code stuff like this

unreal sentinel
#

I'm no expert but it would seem to me you want the server check to make sure duping isnt happening, So client would send a drop request to server indicating the slot from which they want to drop, the server sees whats in that slot and if any is then it removes it and spawns the ground object pushing both changes to the client for graphic updates.

mortal horizon
weak plinth
#

I started playing with unity transport recently and have a question: why does e.g. BeginSend return an int when it's actually returning a variant of Error.StatusCode? Imo the latter is way more descriptive.

#

Also, has anyone got their samples to work? The ping sample doesn't work for me at all, it spams the console with "error on receive ..." before even starting the connection

fickle geode
#

I'm really scratching my head why does not work? (not before or after socket.Bind()).
socket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);.
it gives me SocketException: An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call..
Code is working fine on inside NAT, but I can not get it punch a hole with a match matching server. (Wireshark says Destination unreachable, Port unreachable)
Has anybody done a custom UDP implementation with NAT hole punching? I can connect just fine with port forwarding but nowadays I feel like users don't know how to do that anymore.

humble socket
#

Is anyone else having issues connecting to Photon right now? My Photon Networking suddenly stopped connecting...

mortal horizon
humble socket
#

Nevermind its working...

south palm
#

can someone give me some ideas on how to debug my multiplayer game?

#

left/right rotation is updating between clients over the sever, but up/down rotation and movement isn't

#

i'm at a loss for what to try

mortal horizon
#

depends on the networking you use man

south palm
#

I'm using Mirror

#

with an aws server

#

Mirror uses a component called a NetworkTransform to send transform data over the server

#

the one on my player looks like this

spring crane
#

Scripts that locally control those things are generally sus, so the most likely reason is that something is overriding those things when they shouldn't.

south palm
#

because all of my code is called from update

#

and in Update, FixedUpdate, and LateUpdate, I have at the beginning of the function:

        if (!isLocalPlayer){
            return;
        }```
spring crane
#

And...

#

Are those scripts disabled?

south palm
#

so my understanding of how this works is that the player changes his position locally

#

then the NetworkTransform component sends that data across the server

spring crane
#

By default the Updates will keep running

south palm
#

right but isLocalPlayer is only true when the player gameObject is spawned by the client

#

so other players' scripts will have isLocalPlayer set to false

spring crane
#

Yea that should solve it

south palm
#

but I already have that code that returns from update if not the local player

spring crane
#

Could have a physic object drop from the sky or something to see if it's Mirror or something to do with your player scripts

#

It's pretty unlikely for Mirror to be broken in such a specific way 😄

south palm
#

thanks for the suggestion. I added a cube that falls from the ceiling, and with both a network transform and a network identity it didn't show up on the other client

#

the players spawn in and update left/right rotation

#

but nothing else seems to work

mortal horizon
#

@south palm mirror has its own discord where we can pick apart your issue, just Google mirror discord

#

Plenty of helpers there that will know

south palm
#

oh nice!

#

i didn't even know mirror had a discord

mortal horizon
#

Yeah it's the one with the frog icon, don't ask me why they set it to that lol

fickle geode
# mortal horizon You need to use a stun server or implement your own on your matchmaking server

yeah! I've got a match maker server.

  1. Alice hosts a game, connects to master server (MS), MS remembers the connecting public IP/port for Alice.
  2. Bob presses "join a random game", connects to MS, MS remembers Bobs public IP/Port.
    3a. MS then sends a packet to Alice with the public IP/port for Bob, Alice starts sending her game session data to the public IP/Port of Bob (IMCP port unreachable) to open a hole on her side.
    3b. At the same time the MS sends Bob the public IP/port for Alice to Bob. Bob now starts sending "request game info" to Alice on the received IP/Port combo for Alice.

Now the problem is that Alice's packets never arrive at Bob and Bob's packets never arrive at Alice. However both Alice and Bob are able to talk to and receive from the master server. Every example online that I saw seems to use that SetIPProtectionLevel(IPProtectionLevel.Unrestricted) but it's not working for me in Unity.

I'd love any advice on how to debug this. I've tried this yesterday as well with a friend on a different LAN, and it also did not work, I've disabled the Windows Firewall. I know that some third party plugins are available but it my code is very optimized for my game and I would prefer not to rely on a third party plugin. Working well on LAN or WAN + port forwarding, but having the NAT punching would make such a difference. All I need to know is this black voodoo they perform to punch the NAT!

mortal horizon
fickle geode
#

Okay, that is good to know! I'll have to look for other problems.

gleaming prawn
#

Statistics from steam (reference missing) and ourselves show around 85-90% success rate

south palm
#

any idea why my network transform is transmitting left/right rotation perfectly across the server, but up/down rotation and movement aren't being updated at all?

movement:

characterController.Move(moveDirection * Time.deltaTime);```
left/right rotation:
```cs
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);```
up/down rotation:
```cs
spine.eulerAngles = new Vector3(rotationX, spine.eulerAngles.y, 0.0f);```
heady stump
#

You need to explain a bit more about your solution, for example what kind of networking you use; for example Mirror/Photon.. and then show more of your code, this dosnt say much tbh 🙂

fickle geode
#

Alright my isolated test case seems to work (so it is possible at least for my router pfew), so here is the code for UDP NAT traversal if anybody runs into the same issue at some point. Note that a rendezvous/master server needs to be running somewhere (i'll have to leave it as an exercise for the reader). That just needs to capture and resend the public ip:port to both parties wanting to connect to each other. Related terms are STUN, TURN and ICE. Missing features: no support for local LAN (192.168..)! Does not work on a single NAT (two computers connecting to the same network) due to hairpinning which confuses the router. Disclaimer: not all types of routers/LAN are able to do NAT punchthrough your milage might vary.

https://pastebin.com/QNuPYjkm

south palm
#

the network components on the player look like this:

woven pumice
#

Anyone know what's wrong with this code? (I'm making a multiplayer card game, there are two sides, when one client draws cards, on their end it should appear on the player area while on the other client's end it should appear on the player area, however this doesn't happen at all.)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;

public class PlayerManager : NetworkBehaviour
{
    // PUBLIC VARIABLES
    public GameObject Card1;
    public GameObject Card2;
    public GameObject PlayerArea;
    public GameObject EnemyArea;
    public GameObject DropZone;

    // LISTS
    List<GameObject> cards = new List<GameObject>();

    // OnStartClient is called before Start, and is only run by the Connecting Client
    public override void OnStartClient() 
    {
        base.OnStartClient();

        PlayerArea = GameObject.Find("PlayerArea");
        EnemyArea = GameObject.Find("EnemyArea");
        DropZone = GameObject.Find("DropZone");
       
    }

    [Server] // Prevents the client from executing the functions embedded beneath
    
    // OnStartServer is called before Start, and is only run by the Hosting Server
    public override void OnStartServer()
    {
        cards.Add(Card1);
        cards.Add(Card2);
    }
    
    [Command] // Marks the below functions as server commands
    public void CmdDealCards()
    {
        GameObject card = Instantiate(cards[Random.Range(0, cards.Count)], new Vector3(0, 0, 0), Quaternion.identity);
        card.tag = "PlrCard";
        NetworkServer.Spawn(card, connectionToClient);
        RpcShowCards(card, "Dealt");
    }

    [ClientRpc]
    void RpcShowCards(GameObject card, string type)
    {
        if (type == "Dealt")
        {
            if (hasAuthority)
            {
                card.transform.SetParent(PlayerArea.transform, false);
            }
            else
            {```
#

                card.transform.SetParent(EnemyArea.transform, false);
            }
        }
    }
}
woven pumice
#

nvm i fixed it lol

woven pumice
#

Never used Photon so I can't help ya, soz ;-;

weak plinth
#

Hello everyone! I'm having trouble understanding the Unity Multiplayer Networking (Netcode). I don't trully know how to implement my rigidbody2d based movement into multiplayer with the ServerRpc and ClientRpc, i'm a bit puzzled !

weak plinth
#

hey guys how to fix error CS0111

south palm
# weak plinth hey guys how to fix error CS0111

a quick google found me this:

The namespace '<global namespace>' already contains a definition for 'PauseMenu'
This error means that you've written a class with a certain name, but there is already a class with that name in your project. You can't have two classes with the same name unless they are in different name spaces.

Some possible causes of this error are:

  1. C#, Unity, or an asset that you installed already had a class named PauseMenu
  2. You wrote a script named PauseMenu and accidentally made a copy of it.
  3. You updated an installed asset with scripts and for some accidental reason, it created a duplicate of the script instead updating the existing script.
weak plinth
#

So how to fix it

south palm
#

what is the text of the error?

weak plinth
#

It says Type MenuManager already defines a member Called 'OpenMenu' with the the same paramter types

south palm
#

I assume you haven't written any code where you call something OpenMenu, have you?

weak plinth
#

here I will show you the script

south palm
weak plinth
#

yep

south palm
#

have you written any classes in your code

weak plinth
#

yep MenuManger

south palm
#

ok, so you declared a class called MenuManager?

weak plinth
#

yes

#

So I have to declare a new class

south palm
#

so the error you're getting seems to be because your MenuManager class has two members called the same thing

#

namely, OpenMenu

weak plinth
#

Oh Ok

#

So I have to remove the member OpenMenu

south palm
#

just rename it to something else

weak plinth
#

Ok

south palm
#

try Open_Menu or something

weak plinth
#

Ok

#

Tried but still

#

Same thing

#

Ok I solved it thanks

potent ruin
#

anyone have a good tutorial for the basics of networking with MLAPI?

#

well, for the basics of networking in general. I've looked through the official docs but the information is a bit scattered

cinder vector
#

Hey guys, im using PUN2 from photon for a unity project, but when I call a PunRPC method i get this error:

Caught exception in OnEvent() for event code 200: System.Reflection.TargetInvocationException

#

.
I'm pretty lost as to what this could be from

#

ThrustSystem is a particle system which is a child of my player

deep knoll
#

JB, not an expert on this matter but my suspicion is that it's getting 'double-called' when there's several keys being pressed. Maybe try isolating the if-else for the mouse1.

south palm
#

ok so I've got a gun script that extends MonoBehavior and it fires a bullet like this:

    private void shoot_primary_ammunition(){
        GameObject fired_bullet = Instantiate(ammo);
        fired_bullet.transform.position = bullet_spawn_point.position;  
        fired_bullet.SetActive(true);
        // raycast
        Vector3 target_point = Camera.main.ScreenToWorldPoint(reticle.transform.position);
        Ray ray = Camera.main.ScreenPointToRay(reticle.transform.position);
        // launch the bullet towards the raycast
        fired_bullet.GetComponent<Rigidbody>().AddForce(ray.direction * fired_bullet.GetComponent<Projectile>().speed, ForceMode.Impulse);
        player.spawn_object_on_network(fired_bullet);
    }```
and that last line is calling this function on my player script that extends NetworkBehavior:
```cs
    [Command]
    public void spawn_object_on_network(GameObject obj){
        NetworkServer.Spawn(obj);
    }```
#

so why are the bullets only spawning clientside and not serverside?

sleek magnet
#

Hey guys, just popping by here to ask if it's worth starting a networked game with Unity's networking system so far.

#

I've made small scale games with previous iterations like uNET, then moved over to Mirror, and made some games there, but ultimately all of them had massive limitations and weaknesses.

#

Is Unity's new networking system MLAPI?... or is it called Netcode for GameObjects? Some places I see the first name, some places I see the other name.

somber drum
hearty dock
prime salmon
#

I'm using Netcode and I would like to sync a trigger of a child GameObject

#

but I can't get it to work

#

the trigger never gets synchronized

verbal lodge
sleek magnet
#

Is it at a point with it's worth starting to build a networked game with Unity's Netcode? Or still too early?

prime salmon
#

how do I get my local LAN IP address using MLAPI (or Netcode)

regal delta
#
     {
         return Dns.GetHostEntry(Dns.GetHostName())
             .AddressList.First(
                 f => f.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
             .ToString();
     }    ```
dull vale
#

hello i have this error

#

Failed to 'network-remove' GameObject. Client is neither owner nor MasterClient taking over for owner who left: View 0 on AK-47 Bullet(Clone) (scene)
UnityEngine.Debug:LogError (object)
Photon.Pun.PhotonNetwork:RemoveInstantiatedGO (UnityEngine.GameObject,bool) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:802)
Photon.Pun.PhotonNetwork:Destroy (UnityEngine.GameObject) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2785)
Com.Artur.FpsGame.BulletScript:OnCollisionEnter (UnityEngine.Collision) (at Assets/Scripts/BulletScript.cs:32)

#

idk how to solve it

shell halo
#

Hi there,
can somebody please tell me, why I can not find any Method to disconnect the NetworkManager when using netcode 1.0.0?
According to this documentation: https://docs-multiplayer.unity3d.com/docs/components/networkmanager
there should be a call like: "NetworkManager.Singleton.StopClient();"

But I can not find anything like this in my code. The methods for starting the server/client work fine though.

olive vessel
inland sand
#

Is mlapi still in beta?

#

and would I have to use different transport to get rid of port forwarding?

austere yacht
inland sand
#

So is it still in beta?

austere yacht
#

Well, it is 1.0.0 but ‚preview‘ … whatever that means

#

usually 1.0.0 means ‚stable‘ as far as the api is concerned…

#

In terms of documentation and examples/resources it has long way to go (compared to mirror). So kinda beta in that regard.

inland sand
olive vessel
#

Yeah there's a lot of similarities, so you might find that systems that work in Mirror are easy to translate over to NGO

austere yacht
#

Devil is in the detail

#

and netcode hasn’t nearly as many ready made components to use

vital hawk
#

if they release 1.0, it will be 1.0.0 without anything extra, but in past they've often also bumped the package a bit before first stable

austere yacht
#

Isn’t that what I said?

vital hawk
#

ah, I thought there was some confusion, mb

austere yacht
#

i wouldn’t rely on convention and anecdotal evidence when stability of unity api is concerned

austere yacht
#

Based on that, pre is effectively stable

vital hawk
#

lol

#

but yeah, exp packages can be stable too, main difference is that API can change a whole lot more during experimental phase

#

but even with released packages, that's nowhere given it's not going to have totally different API on future version

austere yacht
#

ther is no stable ‚after the fact‘.., stable is a promise of ‚no breaking changes‘

austere yacht
vital hawk
#

ok I'm not trying to bring some debate here, carry on

boreal stag
#

i have a project I will be starting and I am unsure if unity owuld be the best thing for it. It is a 2D project with a lot of peeps inside.

swift epoch
#

(Using Mirror. This script is attached to the player object, which has client authority)

This section of code produces this error

Disconnecting connId=0 to prevent exploits from an Exception in MessageHandler: ArgumentException The Object you want to instantiate is null.
  at UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) [0x00049] in <a0ef933b1aa54b668801ea864e4204fe>:0 
  at UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) [0x00001] in <a0ef933b1aa54b668801ea864e4204fe>:0 
  at PlayerController.UserCode_CmdSpawnObject (UnityEngine.GameObject prefab, UnityEngine.Vector3 position, UnityEngine.Vector3 rotation) [0x00007] in D:\Github\Artifacts-of-Punishment\Artifacts of Punishment\Assets\Scripts\Player\PlayerController.cs:54
#

But this section of code works completely fine, spawning an enemy on the server. I believe the reference is being lost when it moves to the command. Does anyone know why this would be?

mortal horizon
#

@swift epoch you can't send prefab over the network

safe sand
mortal horizon
#

correct, only way you can send gameobject is if its already network spawned with an identity

swift epoch
#

I modified it so it just used NetworkServer.Spawn in [Client]. Does that even work?
I broke my networking so I can't test it over that, but it works great locally

mortal horizon
#

No you can't use network server spawn in client context

#

It won't sync

#

only server can spawn

swift epoch
#

Oh, so what would you guys recommend then?

mortal horizon
#

you can either redesign to make it so that the server doesn't need to be told what to spawn, or you can get the index of the prefab in the spawnable prefab list and send that instead then look it up on server

swift epoch
shell halo
brittle bronze
#

Is there any sample with Netcode for GameObjects and authoritative physics?

swift epoch
#

(Using Mirror) How am I supposed to use NetworkBehaviours on children? I tried researching NetworkTransformChild but it doesn't seem to do what I want, and absolutely nothing is helpful on that

It's incredibly inconvenient that this doesn't seem to be supported whatsoever

bold pasture
#

Do you guys recommend "Unity Gaming Service" for work on cross platform stuff?

indigo thicket
#

Hey guys, has anyone used SteamP2P with MLAPI?

#

I've imported the packages with no errors, and I can use some scripts (like adding the Steam p2p transport script to a gameobject), but I can't do "using MLAPI.Transports.SteamP2P;" or "using Steamworks;" to use the steam matchmaking functions in my scripts 😦

#

However if I edit the SteamP2P transport script I can clearly see the "using Steamworks" implementation and the "namespace MLAPI.Transports.SteamP2P" 😕

#

Maybe it's because I installed SteamP2P manually via disk, and not via git, but installing it via GIT throws me this error:

verbal lodge
#

Which version of MLAPI are you using?

indigo thicket
#

0.1.0

#

[Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/Unity-Technologies/mlapi-community-contributions.git?path=/Transports/com.mlapi.contrib.transport.steamp2p]:
Cannot checkout repository [https://github.com/Unity-Technologies/mlapi-community-contributions.git] on target path [Transports/com.mlapi.contrib.transport.steamp2p]:
Error when executing git command. error: pathspec 'Transports/com.mlapi.contrib.transport.steamp2p' did not match any file(s) known to git

indigo thicket
indigo thicket
#

Okay, it worked perfectly... What did I do wrong? 🤔

#

I found a topic in the Unity Forum where I downloaded a demo, which uses both MLAPI 0.1.0 and SteamP2P 1.0.0

#

funny enough you also replied to the topic, but the link you gave is the link that I used, without the "#release-0.1.0" at the end

prime salmon
#

Can I use Netcode for GameObjects in my Nintendo Switch game?

vast apex
#

So I have a simple network game but it only works locally but I am pretty sure it should work between other PC's as well if anyone wants to please look at my code and tell me why i cant connect to another PC . I have also found something that might cause this bcs I think my port is closed on my router but I currently have no way to open it havehttps://pastebin.com/Mpb4g3Cd

fickle geode
#

Note that for some users on restrictive routers this will not work, and ideally you'd relay (forward) all your traffic through the master server.

#

But at that point I'd look into using something like Steam P2P or Photon (i have no experience with either)

vast apex
#

cuz I dont have that I am trying to host the game on the players PC

swift epoch
#

(Using Mirror) Does anyone know why I'm getting this error?

NullReferenceException: Object reference not set to an instance of an object
ArenaManager.OnStartClient () (at Assets/Scripts/Networking/ArenaManager.cs:36)
Mirror.NetworkManager.StartHostClient () (at Assets/Thirdparty/Mirror/Runtime/NetworkManager.cs:520)
Mirror.NetworkManager.FinishStartHost () (at Assets/Thirdparty/Mirror/Runtime/NetworkManager.cs:499)
Mirror.NetworkManager.StartHost () (at Assets/Thirdparty/Mirror/Runtime/NetworkManager.cs:448)
Mirror.NetworkManagerHUD.StartButtons () (at Assets/Thirdparty/Mirror/Runtime/NetworkManagerHUD.cs:72)
Mirror.NetworkManagerHUD.OnGUI () (at Assets/Thirdparty/Mirror/Runtime/NetworkManagerHUD.cs:38)
#

I tried doing it on the player object itself, but the host doesn't seem to have authority over their own player?

indigo thicket
#

Hello, I'm trying to debug my MLAPI game made with SteamP2P. Is there a way to debug clientside from the editor? I can connect from another game via steam to the client, but I can't join a game with the editor's game, and uploading the build every time seems so time consuming...

hasty mesa
#

Hey I'm following this tutorial https://www.youtube.com/watch?v=93SkbMpWCGo&t=328s(step 7) and I'm getting this issue where the camera and player glitches out when another person joins ive been triyng for so long to fix it but im getting very annoyed i could vc if you need to show you the whole problem

fickle geode
fickle geode
# vast apex with master server you mean something like a dedicated server right

No, there would be a player that hosts the game, a player that wants to connect to the host and a "helper" server that connects the two players together (outside both players NATs). But really, if it's difficult, I'd recommend looking into a third party solution such as Steam P2P or Photon. They offer this "helper server" for free, and will even relay your traffic for free (up to a point) if NAT traversal fails

indigo thicket
#

What happens if a player fails to connect with Steamp2p (and mlapi)? The callbacks gets called if the player successfully joined the lobby, otherwise what happens? How can I debug that?

fickle geode
#

Mnn sorry I don't have any experience with Steam P2P or MLAPI

weak plinth
#

Will cloud save will be paid after beta?

weak plinth
#

How many players can be played at once in netcode?

olive vessel
#

I don't believe there is a hard limit to the amount of connections, you can adjust that field. There is a practical limit where the lag becomes bad

bold pasture
#

Just downloaded the Unity Lobby demo for the new Unity Game Services, anyone else having issues with it? This is me running the game from the main scene.

#

oh wait think i need to set up my project Id for this one.

#

Tried this because I'm having problems in the project i'm currently working on tho

#

"Unity.Services.Lobbies.LobbyServiceException: HTTP/1.1 401 Unauthorized"

#

Anyone know what that means?

#

sorry if its obvious

#

using System;
using System.Collections.Generic;
using Unity.Services.Authentication;
using Unity.Services.Core;
using Unity.Services.Core.Environments;
using Unity.Services.Lobbies;
using Unity.Services.Lobbies.Models;
using UnityEngine;

public class LobbyManager : MonoBehaviour
{
    public string environment = "production";
    async void Start()
    {
        await UnityServices.InitializeAsync();

        try
        {
            string lobbyName = "Custom Game Lobby";
            int maxPlayers = 16;

            // Lobby options
            CreateLobbyOptions options = new CreateLobbyOptions();
            options.IsPrivate = false;

            // lobby data
            options.Data = new Dictionary<string, DataObject>();
            options.Data.Add("Gamemode", new DataObject(DataObject.VisibilityOptions.Public, "Race", DataObject.IndexOptions.S1));

            //lobby player
            string playerId = AuthenticationService.Instance.PlayerId;
            Dictionary<string, PlayerDataObject> playerData = new Dictionary<string, PlayerDataObject>();
            playerData.Add("Name", new PlayerDataObject(PlayerDataObject.VisibilityOptions.Public, "Steve"));
            
            Player player = new Player(playerId, null, playerData);

            options.Player = player;

            Lobby lobby = await Lobbies.Instance.CreateLobbyAsync(lobbyName, maxPlayers, options);

        } 
        catch (Exception ex)
        {
            Debug.LogError(ex);
        }

    }

    
}

#

heres my code :p

sharp axle
bold pasture
sharp axle
#

Yep that's the one

bold pasture
#

lol after turning it on and off again i've now got a different error

#

heres both of them @sharp axle

sharp axle
#

Oh, make sure you are logged in with Unity Authentication Service

#

I think it's AnonomousLoginAsync() or something like that

bold pasture
#

thanks, that actually did get me further

#

but god damn, a new one

#

I probably should try and do more research, just haven't been able to find much documentation on setting things up for a lobby from the top 😦

#

Unless theres some documentation you'd recommend, I might try and take apart the unity lobby example

severe spear
#

seeking sanity check from the experts 🙇 : I'm working on a moba/td style game with some base building/resource management for up to 4 players. I was thinking of using PUN. Player resources and stats would be synced props, player "commands" (e.g. unit move to position) would be RPC's, and units/enemies would sync their positions, health, maybe a few other things from host to clients (because Unity is not deterministic so things will drift out of sync otherwise). Does that all sound reasonable? Any resources or recommendations that would help me out?

gleaming prawn
#

From Photon, go for Fusion (or quantum if you have a budget, as you can do determinism for that type of game)

#

Being a new project, no point in sticking to PUN, which is being phased-out into maintenance mode

severe spear
#

thanks will take a closer look -- obviously open to any tech at this point -- quantum seems like the right tech for me, but can't justify the cost

#

and again if my outline sounds off any direction welcome 🙂

vast apex
#

Punch through NAT, if you have a server to act as a middle mad, both clients could send a message to the server, the server then sends a message back with the other client's IP and port and then the clients can then send a blank message that will then put the client's credentials onto the list of allowed IPs.

#

I am having a bit of trouble understanding this if anyone could pls help me explain to me the last sentance with what he means the client credentials onto the list of the allowed IP's

#

like how would you do that

#

what list

fickle geode
#

it's not 100% clear from the sentence, but the way NAT punching works is that

  • Alice's data is blocked by Bob's firewall
  • Bobs data is blocked by Alice's firewall
  • Alice sends a message to Sandy (the middle man) with her port 1234, Alice now accepts data on port 1234 to receive the reply from Sandy
  • Bob also sends a message to Sandy with his port 4321 and listens for a response on that port to hear the reply
  • Now Sandy knows, Bob can receive data on port 4321 and Alice can receive data on port 1234.
  • Sandy then tells Alice: "Hey, Bob is able to receive data on port 4321, try sending a message to him there!"
  • Then Alice sends Bob a message on port 4321 and listens for a reply, Bob receives the message because he was listening on that port!
  • In the meantime Sandy also sends a message to Bob, "Hey, Alice is listening on port 1234! Try sending your data there!"
  • So Bob sends a message to Alice on port 1234, and now both Alice and Bob can send each other messages.
    They fall in love, get married, have kids and live happily ever after. And that's how NAT punching works.
#

I think the specific list of allowed IPs is a precaution because people could be randomly sending you data, so in this case: Sandy would have to tell Alice not only the port to contact Bob at, but also what Bob's IP is to expect the reply from. Otherwise it could be Charlie who is a nasty hacker.

molten condor
#

Hey i need help with my project.

#

Ive done a bit of rework today and fixed some issues but for some reasons player cant see weapons anymore, my "animation" is not showed and even the sneaking dont work and i dont fucking know why

#

i have seperated the player model (monkey bean 1) from player_1 so i can scale it without have issues with my camera

#

i have changed nothing to the weapon code or like this but i dont work anymore

molten condor
#

players just see their own sneaking, weapon changed (...

#

but dont see if other player does

vast apex
#

btw your game looks sick I wishlisted it

molten condor
#

ive made a animation with this code but other people cant see the bones moving, any clues?

vast apex
#

are you sending the new position of the bones to the clients

molten condor
#

so i dont know why it dont work to the bones

#

how i can send it to the clients

#

i guess im not doing it

fickle geode
molten condor
#

More tree variation

#

more decoration in the background

#

the trees also looks a bit "glowy"

molten condor
fickle geode
#

yeah! I have to admit as a programmer too much time is spend coding, and not enough time is spend on 3D assets 😢

molten condor
#

they are not very expensive and on your state maybe you can try kickstarter to get some money

vast apex
molten condor
#

Dont release the game as it is it work on it more look very good yet

vast apex
#

what api

molten condor
vast apex
#

dont use that sorry

#

i am also new to this

fickle geode
#

Thanks for the feedback and advice guys, appreciate it! I think I will definitely get somebody from fiver to help me with the graphics 👍

molten condor
#

polishing is very scary

#

but important

fickle geode
#

oof, the time everything takes

molten condor
molten condor
#

and in the end this could be useful for you https://www.youtube.com/watch?v=ht6xx9en-ZU

How do you make a great store page for your indie game on Steam to get more wishlists, downloads and ultimately sales? Professional indie game marketeer Chris Zukowski shares his best marketing and optimizations tips and tricks to make sure your Steam page gets the visibility it deserves. This video is a must watch for everybody who wants to suc...

▶ Play video
fickle geode
#

cool yeah! i'll check it out, it would be especially good to raise some money with a kickstarter, even a little bit..

molten condor
#

if you try kickstarter maybe it could be useful to make a very good trailer of your game or buy it

  • write a good text or buy some from a text writer so you get many clicks / Money
#

u cant avoid costs and 3d models are very hard to make in my opinion.
im not as far as you in my game development but i already spent money on a model cause i cant do it myself and i think its very boring.

#

If you want I can give you the offer to give you some more detailed feedback.
Just ask if you want it to
Some playtesters are always good in my opinion you can also asks friends or something like that.
U can setup a google document with several questions to get good feedback also

#

Can anybody help me? Im using Mirror and have a code for a bone rotation. It works fine but u cant see the head rotation of other people and that confuses me

#

sneaking isntalso displayed to other players so the problem is may my player model or my prefab

#

maybe somebody know about prefabs and can help me

#

The references in my script are not working.

hasty mesa
#

Im having trouble with pun can someone dm me so i can show you the problem its hard to explain

weak plinth
#

How do I Install netcode ? From package manager or from GitHub?

fading torrent
molten condor
weak plinth
#

I want to count who killed who with Photon Pun how can I do that

sour hearth
coarse goblet
#

How do i prevent spamming serverRPCs?
I just want to send the users Input via ServerRPCs. But sending it in the Update() method just looks like spamming
packets to me...

bold pasture
#

are you happy to wait a few frames between?

coarse goblet
bold pasture
#

could always have a frame counter

#

wait till you hit 5 or so frame then send the data

coarse goblet
bold pasture
#

you could wait seconds real time

#

it would get it a little closer

coarse goblet
#

Interesting would be a notification on tick start. Hm. Maybe thats an idea. On tick start: ClientRPC -> Client Checks latest Input -> ServerRPC with Input

bold pasture
#

yeah a request to the clients wouldn't hurt

#

I wonder if you can modify the network variables so they send packets between each other more slowly?

#

if you're using the new input system you could also take advantage of the delegate structure to slow things down too

coarse goblet
#

But clients cant write to network variables as far as i know

bold pasture
#

i'd just use a coroutine then and wait for seconds real time

#

or, use a network variable, i'd imagine it would handle all of that automatically

coarse goblet
coarse goblet
bold pasture
#

you should be able to change ownership

#

and the owner settings of the network variable

coarse goblet
#

Let me check that out. It would solve my problems...

bold pasture
#

wait, did they remove write permissions?

coarse goblet
#

Can i change the owner of NetworkVariables or do i have to change the owner of the parent NetworkObject?

bold pasture
#

I swear you could do it back in 0.1.0

#

I wonder if setting the ownership of the network object would work

coarse goblet
#

Ill try that brb

bold pasture
#

alright gl ^_^

coarse goblet
#

Nope. "InvalidOperationException: Client can't write to NetworkVariables"

bold pasture
#

wow

coarse goblet
#

I cant imagine that the only way to get real time input to the server is to bombard it with Rpcs

#

Unless they handle that internally already

bold pasture
#

oh wow "In the newest implementation they have chosen to remove the ability for clients to change NetworkVariables. You have to use RPC's instead. You can check the NetworkTransform and Samples/ClientNetworkTransform scripts for a way to implement client writing."

coarse goblet
#

Ive written my own UDP based mini game in Java so im a bit conscious about my bandwidth usage...

bold pasture
#

so they did remove writing to network variables from a client.

#

Are you trying to send an input over the network to move the player on the servers end?

coarse goblet
bold pasture
#

like what exactly are you trying to achieve?

#

You might be able to translate the player on the client machine

#

and then if the player moves too far you could rubber band them if it seems hacky

#

thats what ive done at least for what my game needed

coarse goblet
#

I have a 2D Object that is spawned by the Server. I then let a client reference that GameObject.
The client should be able to move this Object with his input.

bold pasture
#

Oh got ya

#

this might be what you need

coarse goblet
#

My 2D Object has a NetworkTransform component

bold pasture
#

Oh dope

#

so if you move the object from the clients perspective it should already sync across the network

coarse goblet
#

But even if i change the ownership of said NetworkObject, the Object does not move.

bold pasture
#

Did you spawn the object in from the server side?

#

using the network manager to spawn in the prefab?>

coarse goblet
#

This is what i do:

    private void Start()
    {
        _clientId = GetComponent<NetworkObject>().OwnerClientId;
        if (IsServer)
        {
            _tank = Instantiate(tankPrefab).GetComponent<Tank>();
            var networkObject = _tank.GetComponent<NetworkObject>();
            networkObject.Spawn();
            networkObject.ChangeOwnership(_clientId);
            networkObject.AutoObjectParentSync = true;
            networkObject.DontDestroyWithOwner = false;

            var clientRpcParams = new ClientRpcParams
            {
                Send = new ClientRpcSendParams
                {
                    TargetClientIds = new[] {_clientId}
                }
            };

            ReferenceTankClientRpc(networkObject.NetworkObjectId, clientRpcParams);
        }
    }

    [ClientRpc]
    private void ReferenceTankClientRpc(ulong tankId, ClientRpcParams rpcSendParams = default)
    {
        _tank = NetworkManager.Singleton.SpawnManager.SpawnedObjects[tankId].GetComponent<Tank>();
    }
#

I just spawn it, change the ownership to a client and then let this one client reference the Object on his side.

#

Via the Objects network ID

bold pasture
#

I wonder if the client rpc params are new

#

i've not touched them yet

#

lol

coarse goblet
#

Is there another way to send the Rpc to only one specific client?

bold pasture
#

I'm assuming thats the correct way to do it tbh.

coarse goblet
#

Otherwise everyone would reference only the latest tank...

bold pasture
#

I just send it to every client because the needed to know a few details about the other players anyway

#

and then only set ownership if the id matched up with the client

#

god my projects now not even work for me to reference things lel

coarse goblet
#

Hm. And everyone could then check locally for the owner id. But the referencing itself works.
The _tank var is not null anymore and Translate/Rotate are called as well. Just nothing happens:

    private void ClientSideUpdate()
    {
        if (_tank == null)
        {
            return;
        }

        var forward = Input.GetAxis("Horizontal");
        var rotWard = Input.GetAxis("Vertical");

        var tankTransform = _tank.transform;
        
        tankTransform.Translate(tankTransform.forward * (forward * Time.deltaTime * 5F));
        tankTransform.Rotate(0, 0, rotWard * Time.deltaTime * 5F);
    }
bold pasture
#

probs shouldn't have updated to the new version of "mlapi"

#

for reference I've been working on a 2D game too

#

and I just used the network transform to do all of the magic

#

however, this is in an older version of mlapi

#

give me a little bit

#

now I'm super confused XD

coarse goblet
#

Yeah but does the client call the transform methods or do you just send Rpcs to the server so that it calls the transform methods

#

On the Object that has the NetworkTransform component

bold pasture
#

Its automatic

#

just update the transform on the client

#

and it should send across the new position

coarse goblet
#

😦

bold pasture
#

and it has a delay between positions sent

coarse goblet
#

And it interpolates. Thats all nice but why does it not work for me then 🥲

bold pasture
#

with automatic interpolation

#

yeah I'm so confused :p

coarse goblet
#

Ill try one more thing

bold pasture
#

you're setting the ownership on the sever

#

then sending across the object's id

coarse goblet
#

Fun fact: If i start as Host then i see movement...

bold pasture
#

so it should work I thought

#

yeh weird

coarse goblet
#

Hm. Let me change the ownership and then spawn it.

#

Not allowed...

bold pasture
#

    [ServerRpc(RequireOwnership = false)]
    public void SpawnPlayerServerRpc(ulong clientId, int deviceId, Color colour)
    {
     
        Unit player = Instantiate(prefab, parent);


        NetworkObject no = player.GetComponent<NetworkObject>();
        no.SpawnAsPlayerObject(clientId);

        var netId = no.NetworkObjectId;


        SpawnPlayerClientRpc(netId, clientId, deviceId);
        player.networkColourHue.Value = Random.Range(0f, 360);


        player.onUnitStatChange += (u) =>
        {
            if (u.stats.currentHp <= 0)
            {
                UnitDeathServerRpc(netId);
            }
        };
    }


  

    [ClientRpc]
    private void SpawnPlayerClientRpc(ulong netId, ulong clientId, int deviceId)
    {
        NetworkObject no = NetworkManager.Singleton.SpawnManager.SpawnedObjects[netId];
        Unit player = no.GetComponent<Unit>();


        if (NetworkManager.Singleton.LocalClientId == clientId)
        {
            PlayerInputHandler.instance.AddPlayer(player, deviceId);
        }


    }

#

alright lets take a look at mine :p

#

got I coded this a bit ago :p

coarse goblet
#

Oh. Thx to you i just discorvered networkObject.SpawnWithOwnership(_clientId);

bold pasture
#

dope :p

#

Oh.

#

You might need to do it all in a ServerRpc?

#

Thats what I did at least

#

Clients, when a device is plugged in (local multiplayer) I make a request to the server to spawn in a player

coarse goblet
#

Hm. I thought

        if (IsServer)
        {

Would suffice

bold pasture
#

It might not

#

I'd nest it all into a ServerRpc and call it

#

and see what happens

coarse goblet
#

Ill try that

bold pasture
#

Oh also, its happening in start too... So shit might be happening before the network even starts... which confuses me as to why you actually are able to spawn in prefabs

coarse goblet
#

So like this:

    private void Start()
    {
        _clientId = GetComponent<NetworkObject>().OwnerClientId;
        if (IsLocalPlayer)
        {
            RequestSpawnServerRpc();
        }
    }

    [ServerRpc]
    private void RequestSpawnServerRpc()
    {
        _tank = Instantiate(tankPrefab).GetComponent<Tank>();
        var networkObject = _tank.GetComponent<NetworkObject>();
        networkObject.SpawnWithOwnership(_clientId);

        var clientRpcParams = new ClientRpcParams
        {
            Send = new ClientRpcSendParams
            {
                TargetClientIds = new[] {_clientId}
            }
        };

        ReferenceTankClientRpc(networkObject.NetworkObjectId, clientRpcParams);
    }
#

Maybe even OnNetworkSpawn() instead of Start()

bold pasture
#

lol bad screen shot

coarse goblet
#

I got you

bold pasture
#
 public override void OnNetworkSpawn()
    {
       //spawn player server rpc 
    }
bold pasture
#

onto it at the same time XD

#

wonder if you can help me back tho, any idea what these errors are?

#

this is after trying to update to the newest version of netcode for gameobjects

coarse goblet
#

Looks like some Rpc tries using null fields or values.
Try running the other side in Unity. It might give you a better idea of what could be null

bold pasture
#

you know what, i have a theory and you might have saved me

coarse goblet
#

Still not moving...

    private void ClientSideUpdate()
    {
        if (_tank == null)
        {
            return;
        }

        var forward = Input.GetAxis("Vertical");
        var rotWard = Input.GetAxis("Horizontal");

        var tankTransform = _tank.transform;

        var isOwner = _tank.OwnerClientId == OwnerClientId;
        Debug.Log(isOwner);

        tankTransform.Translate(tankTransform.forward * (forward * Time.deltaTime * 5F));
        tankTransform.Rotate(0, 0, rotWard * Time.deltaTime * 5F);
    }

This prints True
So i know that:

  1. I have the reference of the Object
  2. I am the owner of the Object
#

And it works in "Host" mode

bold pasture
#

damn 😦

coarse goblet
#

But this works...

    private void ClientSideUpdate()
    {
        if (_tank == null)
        {
            return;
        }

        var vert = Input.GetAxis("Vertical");
        var horiz = Input.GetAxis("Horizontal");

        SendMovementServerRpc(vert, horiz);
    }

    [ServerRpc(RequireOwnership = true)]
    private void SendMovementServerRpc(float vert, float horiz)
    {
        var tankTransform = _tank.transform;

        tankTransform.Translate(tankTransform.forward * (vert * Time.deltaTime * 5F));
        tankTransform.Rotate(0, 0, horiz * Time.deltaTime * 5F);
    }
#

At least in know now that the NetworkTransform does its job

bold pasture
#

Wait have you got it working?

coarse goblet
#

Yes but not the way i want. Now i send an Rpc every time Update() is called

#

And the Server then changes the transform

#

Ok so there is something called a ClientNetworkTransform

bold pasture
#

Wait wot

#

is this a component?

#

lol, my game is broken by one of the issues you got now that they removed clients writing to network variables

#

wonder If i'm going to need that too

coarse goblet
#

In the package description there is an example implementation for client authoritative network transforms.

#

But i think ill just go fully server authoritative.
I just need to find out if packets are automatically batched or if i have to figure out a way to
prevent packet spamming.

bold pasture
#

wtf the documentation says I can still do this ```cs
private NetworkVariable<float> myFloat = new NetworkVariable<float>(new NetworkVariableSettings {WritePermission = NetworkVariablePermission.OwnerOnly}, 5);

#

wait wot

bold pasture
#

looks like my game might be broken now too when it comes to movement

coarse goblet
#

Because i have a custom serializable UserInput class that could be shared like this.

bold pasture
#

it errors

coarse goblet
#

oof

bold pasture
#

they've deprecated it but forgot to update the documentation

#

looks like a lot of client control has been removed in favour for rpcs

bold pasture
#

which is kinda annoying now that I've made my project based on an older way of thinking

#

got this explains my confusion so much XD

coarse goblet
#

What is the best way to get real time input sent to the server.
Calling an Rpc every Update() seems like a bad idea as it bombards the server
with packets. Are they batched internally already or do i have to think of my own solution?

PS: Using client authoritative NetworkVariables was my first idea but clients cant write to them anymore.

bold pasture
#

well you're going to encounter a bit of nasty delay if you send the players input

#

i'd recommend sending the players transform

#

then doing interpolation on the server

#

even if its just the players position :p

#

I might be about to encounter this issue tho

#

lets hope my transform component works still

#

Oh shit I am 😦

#

Clients no longer control the component :(((((

#

@coarse goblet Thanks for pointing out the client network transform

#

that actually fixed my game ^_^

#

its almost working again

#

With how things are I'm now sending data every fixed update frame so the animations work

#

so this is a bit shit

#

however because its animations I can delay it all

shut yarrow
#

FixedUpdate is about 50 times a second so that is very frequent, you can most likely get away by sending it only 10 times per second or only sending a new animation state when the state has changed

coarse goblet
shut yarrow
#

Not sure why that would be bad, if something doesn't change so constantly then it would be a waste to send so many updates

swift epoch
#

(Using Mirror) Does anyone know why this code causes this error, and only on the client? It seems that the client can't access their own object in OnClientConnect

System.NullReferenceException: Object reference not set to an instance of an object
at ArenaManager.OnClientConnect (Mirror.NetworkConnection conn) [0x00011] in D:\Github\Artifacts-of-Punishment\Artifacts of Punishment_clone_0\Assets\Scripts\Management\ArenaManager.cs:27
#

The host gets My player is NetworkPlayer [connId=0] where the client gets the error

mortal horizon
#

Onclientconnect is simply when the client connect attempt was successful, nothing game object related has been spawned yet for the other players

swift epoch
#

So would I just have to do that in some other script?

mortal horizon
#

Onstartlocalplayer on player prefab

swift epoch
mortal horizon
#

it's an override

swift epoch
#

Oh yeah, it didn't get intellisensed, so I assumed it was just a void

swift epoch
#

Just how important is it to minimize bandwidth usage? I find myself worrying about it with every line I write

Is it best to have the clients do all the math and then send the answer back to the server, or just send the raw numbers to the server, and have it do the math? What about moving characters? Should I have them move on the server, or have them move locally and wait for the server to sync everyone else with that? Animations? Particles?

We're using Mirror (although that shouldn't really be relevant to this) and anticheat isn't a concern for our game

mortal horizon
runic rampart
#

I'm wanting a p2p networking solution that's free and am looking at photon bolt. Would this do what I want?

#

I don't need to use photon cloud do I?

swift epoch
mortal horizon
#

Ideally you want to minimize the amount of information sent over the wire

#

Even if the tradeoff is a little more cpu usage

#

but its really a game of balancing when it comes to server auth stuff

#

But if it's all client auth with no care for cheating then you don't need to worry about that part

swift epoch
#

Ok, thanks

#

You've been super helpful, by the way

mortal horizon
#

Np

royal locust
#

Hello, I'm trying to connect a local database to unity, but every time it tries to use the sCon.Open() it crashes, throwing that the conection got rejected from the destiny.

#

Does someone know something about it?

fickle geode
# coarse goblet I would rather just have a fixed time interval that is checked every frame. Wait...

Players usually don't change their input 400 times per second, so instead you can compare the last input to the current input and only send a input packet if the last input if different from the current input. Then program all your clients to repeat the last received input packet for each frame. Note that with UDP you might miss a few packets now and then depending on the connection quality, so I'd recommend sending an input packet every 250ms or "anyway" just to be sure (250ms is years in computer time anyway).

#

or add some sort of protocol that "AWK"s your input packets (also make sure to ignore any older packets then the last one received to avoid out of order inputs)

sharp axle
#

RPCs get queued up and sent in batches. You can also set the Delivery to be either Reliable or Unreliable

coarse goblet
royal locust
#

Hello, does someone know something about it

#

?

indigo thicket
#

Hey guys how can I check if a connection was successful or if a client is connected on a server in MLAPI?

granite yew
#

Hey! ummmm how could i make a simple meeting system for my game? (like in among us)

peak trout
#

Hey, im wondering what networking system the popular mobile games like clash of clans, lords mobile are using? Maybe someone know and want to share this information. What i know is that they have database to store players data and thats all. They've own networking system?

sharp axle
indigo thicket
vast apex
#

I am trying to make an online game but when I host a game and then join with another PC Ic an only move as the host the client cant move this is my code I am using to move. This script is on both players
https://pastebin.com/E1n8Ymuf
I am new and learning mirror so any help would be welcome

peak trout
indigo thicket
#

Yeah, not supercell. Everything depends on the game, and there's no general rule, but most of the times indies goes for Unity and some common solution like Photon or UNet, while big companies make everything from scratch.

shut yarrow
#

You're focusing on the wrong things in my opinion. There are many different networking solutions and it's up to you to research which ones are suitable for the game you're trying to make. The big companies most likely don't use off the shelve solutions, but even if they did how are you sure that's the one you need without researching?

#

I can tell you however that all of them claim to make networking easy but this is very relative. There' still plenty of work that needs to be done, and you have a big responsibility to understand how they work to get it working like you need it to

civic acorn
#

I'm trying to have one instance of a project being played in WebGL streamed to another browser (probably also running Unity WebGL). Any idea how to do that? I think it would be with something like WebRTC. Is there an easy way to do that? Would just need to be the video, wouldn't need to be interactable (although if possible that would be even cooler).

sharp axle
civic acorn
#

I know it is possible to do, was more wondering if anyone has done it and/or knows the easiest way to do it

civic acorn
slow lichen
#

How to send request to server?

#

From different clients

#

If I trying to call Door open function from other clients

#

I gets

#

"Only owner can invoke ServerRPC that is marked to require ownership"

#

Its safe?

sharp axle
slow lichen
#

Okay

#

Thanks

swift epoch
#

I'm getting the following error: (Full text: https://www.toptal.com/developers/hastebin/awahojucaw.sql)

Disconnecting connId=0 to prevent exploits from an Exception in MessageHandler: NullReferenceException Object reference not set to an instance of an object
  at Mirror.NetworkIdentity.OnStartServer () [0x00085] in D:\Github\Artifacts-of-Punishment\Artifacts of Punishment\Assets\Thirdparty\Mirror\Runtime\NetworkIdentity.cs:659

From line 25 here. Both of the debug logs run and give the expected result, so I'm not sure what's causing this

I'm calling it from here on the client (although playing as host): CmdSetUpLocalObjects(NetworkConnection.LocalConnectionId);

teal obsidian
#

Anyone in here ever experiment with reconciliating rigidbodies in physx?

#

I've found that it works fine with a car on 4 custom wheel colliders, but the second the car body hits another collider, (like the front bumper hitting a wall or terrain), you get mispredictions up the ass

#

This is an ongoing issue for me, 6+ months now, and yes, I've quadruple+ checked that everything matches between scenes. The cars, maps, etc are 100% identical. There's nothing wrong with my reconciliation algorithm, otherwise I wouldn't be getting perfect predictions while the car is driving on 4 wheel colliders

azure lantern
#

Hi guys, i'm a bit lost on something...
I just started to create a project oriented for multiplayers, but tipping Unity multiplayer game, sent me to MLAPI, and follosing some links i landed on Netcode for gameobjects.
so i don't understand witch one should be used
any clue ?

#

it seems that MLAPI is finally the old one, and Netcode for gameobjects the right choice ... am i right ?

austere yacht
azure lantern
#

@austere yacht ok, good, i'm on the right way, thanks

blissful kayak
#

Has anyone done anything with client side predictions?
I just a few questions based on a few bugs im having with it

teal obsidian
#

@blissful kayakRigidbody or character controllers

blissful kayak
#

@teal obsidian physx

teal obsidian
#

Is it a vehicle or what

blissful kayak
#

physics based characters

teal obsidian
#

Physx doesn't like to be reconciliated if theres collisions involved

blissful kayak
#

when there is any latency my characters freak out

teal obsidian
#

I'm in the process of trying to find a workaround

#

yeah

#

physx hates to be reconciliated

blissful kayak
teal obsidian
#

Are you using a third party service or something?

#

for your netcode

blissful kayak
#

Yes Im currently using mirror for the base

teal obsidian
#

yeah I've never worked with mirror or any third party services so I'm no help there

blissful kayak
#

but you have done physx client side predictions

teal obsidian
#

I've done it with wheel colliders

#

it still shits itself when the actual body collides with another collider such as when the bumper hits the terrain

#

as far as I'm concerned its impossible when you have real collisions going on

blissful kayak
#

right, well thanks anyway. imma keep trying

teal obsidian
#

I just posted this about an hour ago

#

you can try commenting your issue there to see if it gains any traction

blissful kayak
#

thanks

teal obsidian
#

I've tried making posts like this in the past, didn't get any feedback from unity staff

#

I wouldn't expect much

#

As for your situation, you can either
A.) Send the inputs to the server, don't predict on the client, and just have the server send new position/rotation data for your players
B.) Not use rigidbodies for your characters

blissful kayak
#

@teal obsidian this is what I have been basing mine off. It is with 150 ping and no interpolation.

#

they are different interactions events

teal obsidian
#

you can see the cubes spazz out when they collide with each other

#

tell me you see that too

#

on the client part

blissful kayak
#

Yes I do see that but am expecting that with moderate ping and not interpolate. so for my game I dont mind as much as input lag, especially when I try to smooth out the movement

south palm
#

can someone who uses Mirror explain to me what I'm doing wrong? I'm trying to spawn a bullet such that both clients can see it

#

I have code on my gun script that extends monobehavior

#
    private void shoot_primary_ammunition(){

        player.spawn_object_on_network(ammo, reticle, bullet_spawn_point);```
#

it calls a function on my player script, which extends networkbehavior

    [Command]
    public void spawn_object_on_network(GameObject obj, GameObject reticle, Transform bullet_spawn_point){

        GameObject fired_bullet = Instantiate(obj);
        fired_bullet.transform.position = bullet_spawn_point.position;
        fired_bullet.SetActive(true);

        // raycast
        Vector3 target_point = Camera.main.ScreenToWorldPoint(reticle.transform.position);
        Ray ray = Camera.main.ScreenPointToRay(reticle.transform.position);

        // launch the bullet towards the raycast
        fired_bullet.GetComponent<Rigidbody>().AddForce(ray.direction * fired_bullet.GetComponent<Projectile>().speed, ForceMode.Impulse);

        //spawn the bullet on the server
        NetworkServer.Spawn(fired_bullet);
    }```
#

the variable I call "ammo" is a bullet prefab with a network transform attached to it

#

yet when I call this function, nothing happens, and the bullet doesn't appear for either client

#

what am i doing wrong?

blissful kayak
#

@south palm and its not appearing in the hierarchy?

south palm
#

yeah. someone on the mirror discord said it's because I can't pass prefabs to the server?

#

so I'm trying to instantiate from the list of registered prefabs and see if that works

blissful kayak
#

@south palm yea if the object is not in the registered prefabs it will not spawn, but it should give u an error.
Also, from you code it might not spawn the object in the correct position, as from my experience the network.Spawn() just instantiates the object on all clients

south palm
#

how do you put it in the correct position then?

south palm
blissful kayak
#

do you have a server and then two clients connect or a host and a client?

south palm
#

I changed the instantiate code to this:

GameObject fired_bullet = Instantiate(nm.spawnPrefabs[1]);```
#

and it's still not spawning

blissful kayak
#

can u look at the server will its running?

#

as in, in unity

south palm
#

I mean it runs headlessly

#

all I see is the linux output in the terminal

blissful kayak
#

ok, so is the only play to play the game is through only builds or can the edit, be the server or a client?

south palm
#

yeah I play one client in the editor, then I create a windows build and a linux server build

#

and i play the other windows build as an exe

#

and I upload the server build to my server

blissful kayak
#

yep ok, and while u play in the editor nothing spawns in the hierarchy?

south palm
#

yeah nothing

#

it seemingly calls the function because there are no errors or warnings, just whatever debugs I put in the client side

blissful kayak
#

can u see debugs on the server in the terminal?

south palm
#

debugs I put in the [command] function don't appear in the terminal

#

debugs I put in any other function appear clientside

blissful kayak
#

I havent worked with a dedicated server, i have a host a clients

south palm
#

hmm

blissful kayak
#

can u do a developer linux build?

south palm
#

you mean a development linux build?

blissful kayak
#

yes

south palm
#

server or client?

blissful kayak
#

and enable debugging

#

server

#

client u can see in editor

south palm
#

my server build is already a development build

blissful kayak
#

unless u can have windows builds that can connect to the editor as the server

south palm
#

and debugs don't show up in the terminal output

tender moth
#

Hi, i'm trying to add client side prediction / server reconciliation (with physics) to my multiplayer game.

Sometimes the player is juddering when the local-state and the server-state is too different.
Another problem is jumping. If an old input-state is rewinded, the player is jumping again if the jump-key was pressed in the old state.

Can someone tell me how to fix this, or what i'm doing wrong?

teal obsidian
#

@tender mothYou should reconciliate every tick regardless of client/server position of the player

tender moth
#

@teal obsidian ok, i will try. But how to handle jumping? If i rewind every tick, i will alwasy jump 2 times...

teal obsidian
#

then your code is probably wrong

#

because that shouldnt happen

#

your reconciliation code should be running the same stuff as the normal simulation

#

so reset player position, rotation etc, then check if your player pressed jump that tick, then check if the player is currently grounded, etc

#

you don't re-use anything except for inputs

tender moth
#

hm so this means if i press jump - im jumping - but when i rewind the input a few frames later, im not grounded so i dont jump again?

teal obsidian
#

its a bit of a brainfuck to try to explain it in laymans terms

#

but if the reconciliation works, then it should look as if nothing has happened

#

since you're simulating until the present tick

#

so at the end of the reconciliation event, you should end up exactly where you were before reconciliation occured

#

unless the client mis-predicted for whatever reason

#

Are you using rigidbodies or character controller?

tender moth
#

rigidbodies

teal obsidian
#

physx hates to be reconciliated just an fyi

#

especially if any collisions are happening

#

I got it working with a car since its basically a hovercraft with wheel colliders, but if I smash into something, it flickers and mis-predicts like crazy

#

other people like fholm and roystan claim to have gotten it working with collisions

tender moth
#

hm ok ;/

gleaming prawn
#

if you have a proper rollback (that resets everything), it works, except enter/exit would be unreliable on clients

#

But the actual behavior of physics can be fully predicted, of course.

#

it flickers and mis-predicts like craz
This looks like something is done wrong.

teal obsidian
#

I mean I've had the problem for 6+ months

#

joy looked over my reconciliation code for rigidbodies, said theres nothing wrong

#

works flawlessly as long as the RB is gliding on wheel colliders

#

no difference in position/rotation between client/server

gleaming prawn
#

Here's a "claim". What about Ragdolls?

teal obsidian
#

Haven't tested, have no need for it

gleaming prawn
#

Watch above.

teal obsidian
#

yeah I don't get how you guys got it working yet I cant

#

so odd

#

I'll upload a vid of the flickers