#archived-networking
1 messages ยท Page 44 of 1
He just means make your changes through a method that also sets your dirty flags I believe
Not an actual PUN built in thing
you wouldnt want that anyway
the concept of "dirty" is really on you and your data design
So don't just change values, change them through a property or a method that also sets your dirty flags accordingly for the change made
ok yeah i'm doing that
i realize bitshifting would be a cleaner way to pack/unpack bits here but to me this just makes more sense so for now, is this a reasonable appraoch to OnSerializeView
I have a writer for that if you want to just use mine
literally can bitpack right into and out of a byte[]
maybe i will here when i'm a little more settled down
thanks
for now just trying to slog through the meat of it
i'll suss out the details later, as long as them bits get packed /unpacked i don't care if theres some extra if()'s in ther efor now
really just... so frustrated by this right now
its hard to explain how much pressure i'm under to make this game real, finished, and successful
yeah, that's a bad idea
where is that pressure coming from?
oh amnod thanks, whoops
yw
๐
yeah, networking is not the place to put your foot into the pool for that @earnest wave
I'm 2 years into it and only now feel like I am qualified to make a proper game
well i've done a bit of multiplayer networking before
with unity's library, and i wrote client/server for flash games years ago
ahh, nm then
i just... can't finish anything
yeah, that's networking
Main thing is to not drown in the big picture
you need to be aware of it, but when coding you code VERY small parts at a time
The goals thing... can't help there. That's just ADD in general
do i have to make changed data as dirty explicitly with pun somehow?
the code snip i pasted earlier is working now with reliable on change but only the first time a non master client picks up a stone
after that, no update.
i'm using an array of custom data types that I defined and registered and am successfully serializing and deserializing
nice
thanks
i still don't feel really solid about how i'm doing it though
it just seems like photon is trying really hard to make this easy for me and i'm just making it much harder than it needs to be
If you are serializing there is nothing PUN related tracking dirty and such... you just are being asked by OnSerialize .. "Do you have anything to say?"
That's the case with any HLAPI for networking
they do a lot of stuff for you, but it does require you to do it the way they wrote it
do i have to explicitly mark my arrays as dirty for pun to actually call onserializeview on the non master clients/
?
because with reliable on change only the first change is going through
I don't believe it has any way of knowing, unless your data is derived from some class or something they provide (not aware of any)
Pun will call onserializeview on a regular schedule of some kind, forget what that timing is based on
Its a unified method isn't it? One method for both read and write?
It should only call with isWriting being true when the photonview has authority though, pretty sure
On dumb clients it is a callback for when that photonview has an event right?
on clients it just calls when it feels like calling i guess
i can't make sense of it
yes it's unified
it's only isWriting on the masterclient for this scene-owned object i'm trying to serialize
its a callback, so it will get called on clients when it has something
The timing is in FixedUpdate, that is when the incoming message queue gets dispatched (in PUN2)
in PUN1 it was in Update()
There is a Photon singleton called PhotonHandler I think that manages that stuff
Its a weird callback, because it has two sources
If it has authority, the source is the send rate timer
If its not the authority, its the callback for incoming messages
i don't think the timing is the issue, it's whether it happens at all
theres some sort of flag in the mix I think, 'hasChanged' or something like that
If its not happening, then likely the message is not getting generated
Are you debugging your OnSerialize write to make sure its actually writing something there?
yes it's definitely writing
if i change it to Unreliable it works
so for now, that's what i'm doing... but... packet loss
Ahh, it might be doing a delta compare to the objects (ick)
little worried about that especially since its a mobile game
they're all instances of a class, maybe it expects new instances in order to trigger that update?
i dunno
try changing something minor, like at a int counter to the front of the write? So you know its changing
If its not sending, it may be doing a rough delta check, and your data isn't changing
yah it only sends if something changed anyways
right now its just an int that changes from 1 to some weird negative number (negative stone-holder viewID)
Not sure then, if its having your write in OnSerialize... I would expect that to send. But again - haven't used it much.
I don't like wondering what its doing, I just to right to raise event myself to avoid any of this wondering
yeah still havent ruled that out
just want to really get a headlock on this serializeview
so if i choose not to use it, it's not for a lack of ability to, it was a deliberate decision
Sounds like he is getting nothing past the first,which seems a bit much to be pl
PUN does pass everything as objects, so it might be seeing that its the same reference and calling that the same yeah @earnest wave
hmm
yes still here
ok so if i send an array of custom classes as Unreliable, they send, each time i trigger a new send. Not sure they always receive but apparently they usually do
if i send as Reliable, they send the first time and thats it
i'd prefer not to create new instances of those classes every time i want an update that seems lol.
and yes multiple tests always same result, first is consistent then never again
so i'm doing something wrong.
Yeah, that clearly sounds like its check for delta is coming up with the conclusion its the same
so sending the same ref with changes is no good
but, good news is my custom class serialization / deserialization / registration with Photon is all working a champ
You will find PUN as a garbage collection generating machine.... another reason I avoided all of this
with byte[] you can send partials in a wrapper
However, that technique may work for you if you are writing to a byte[] ?
(hint... you should be serializing to a byte[])
{
int bytepos = (bitposition + 7) >> 3;
System.ArraySegment<byte> byteseg = new System.ArraySegment<byte>(buffer, 0, bytepos);
optsTarget.TargetActors[0] = connId;
PhotonNetwork.NetworkingClient.OpRaiseEvent((asServer ? SVR_TO_CLIENT : CLIENT_TO_SVR), byteseg, optsTarget, sendOpts);
if (!Time.inFixedTimeStep)
PhotonNetwork.NetworkingClient.LoadBalancingPeer.SendOutgoingCommands(); //.Service();
}```
My PUN2 send code
System.ArraySegment<byte> is pretty critical to keeping it from spewing out garbage
yeah i serialize to byte and if needed i could just serialize the entire array of custom classes to a big long byte stream i'm just trying to keep it all as HL as possible
If you are writing to byte you need to use System.ArraySegment<byte> anyway
And those are triggering the dirty? Odd
[System.Serializable]
public class StatusStone
{
public int status;
public Vector3 location;
public StatusStone()
{
}
public static object Deserialize(byte[] data)
{
var result = new StatusStone();
int offset = 0;
int nibble = 0;
nibble = sizeof(int);
result.status = UtilitySerialize.BytesToInt(new ArraySegment<byte>(data, offset, nibble).Array);
offset += nibble;
nibble = 12;
result.location = UtilitySerialize.BytesToVector3(new ArraySegment<byte>(data, offset, nibble).Array);
offset += nibble;
return result;
}
public static byte[] Serialize(object customType)
{
var c = (StatusStone)customType;
List<byte> obytes = new List<byte>();
obytes.AddRange(UtilitySerialize.IntToBytes(c.status));
obytes.AddRange(UtilitySerialize.Vector3ToBytes(c.location));
return obytes.ToArray();
}
}
You are serializing to them as well right?
public class UtilitySerialize
{
public static byte[] IntToBytes(int inVal)
{
return BitConverter.GetBytes(inVal);
}
public static int BytesToInt(byte[] inVal)
{
return BitConverter.ToInt32(inVal, 0);
}
public static byte[] Vector3ToBytes(Vector3 inVal)
{
byte[] oBytes = new byte[12];
Buffer.BlockCopy(oBytes, 0, BitConverter.GetBytes(inVal.x), 0, 4);
Buffer.BlockCopy(oBytes, 4, BitConverter.GetBytes(inVal.y), 0, 4);
Buffer.BlockCopy(oBytes, 8, BitConverter.GetBytes(inVal.z), 0, 4);
return oBytes;
}
public static Vector3 BytesToVector3(byte[] inVal)
{
Vector3 oVec = Vector3.zero;
oVec.x = BitConverter.ToSingle(inVal, 0);
oVec.y = BitConverter.ToSingle(inVal, 4);
oVec.z = BitConverter.ToSingle(inVal, 8);
return oVec;
}
}
by triggering the dirty i'm not sure what you mean
btw there's a lot of room for optimization here i'm just trying to keep it readable for now
I mean sending something that PUN Reliable sees as different than the previous send
sec i'll paste the serialize
I suspect its just running a hashcode on the objects you feed it
{
var c = (StatusStone)customType;
List<byte> obytes = new List<byte>();
obytes.AddRange(UtilitySerialize.IntToBytes(c.status));
obytes.AddRange(UtilitySerialize.Vector3ToBytes(c.location));
return obytes.ToArray();
}``` I don't see that using ArraySegment
I don't fully follow what you are doing, but it looks like you might be doing some pointless stuff there
Why the object uses and just just straight up byte[] everywhere?
feel free to change it up how you would do it and i'll try it out
I can't poke around without it being in VS.. .but the use of object anywhere rather than byte[] seems bit odd
i'm not married at all to the serialize / deserialize its just what is basically functional at this point
I would have a reusable byte[].... clear it and write to it... then ArraySegment it off to OnSerializeView
Just makes it hard at a glance to tell what the object is and where it would be coming from
normal flow is pretty basic for this stuff... serialize to a byte[] ... hand that to the transport.... get a byte[] back... hand that to the various things that need to read it
If you turn your byte[] into a ArraySegment and give that to PUN, it will come out the receiving end as a byte[]
Other side note... doesn't have to be byte[] most likely for PUN a ulong[] would work I suspect. I just use byte[] so my libraries work with all transports
i've just been trying to keep to the PUN docs/samples as much as possible
they used byte[] in/out so thats what i went with
I would really avoid that for anything you want to optimize
ahh, the byte thing is fine, thats standard
dont care about optimization at this point just want it working and reliable
just ulong[] offers faster bitpacking and such
yeah, byte[] is the way to go then
however, that reliable method with its automatic whatever for detecting changes seems like more hassle than help
there will come a day when its all working and we can sit down and tear it to pieces
I would really just raise your own events
i'm compartmentalizing all the bottlenecks so it should be easy to address them one at a time
I think that reliable delta option is meant for beginners, not for advanced stuff
if you send reliable events, you can do your own delta check
how did i leapfrog from 'knows nothing' to 'advanced' ๐ค
You are aren't just RPCing structs and values
i see
I suspect you are trying to serialize objects, and they are hashcoding out as unchanged
Just guessing, really you can find out for sure by just following the code and see what it is checking
maybe i need to use unity's internal 'mark as dirty' mechanism?
Not even sure how that would interact, but I would avoid all of that
your data set is going to need you to manhandle that anyway
i think the unity mark as dirty is an Editor thing anyways
Later down the line you are going to want to decide how to fragment the sends, and what to repeat and what not to repeat
yeah, its not really related
regardless.. I would just use a mechanism that sends every time - and add code later for culling those sends
Or, dig a bit and see what the check is in Photon
it should be uncompiled C#
yah for now that's the plan, if there's packet loss it'll get fixed up the next time someone triggers an update
and all game referee actions are conducted by the master client anyways so it's not like loss of sync means someone can pick up a stone twice etc
Eventual consistency works for most things, its my preference when I can avoid reliable
I generally focus my energy on making things self correcting
rather than dealing with order of execution and events nightmares
Hey! Quick question (hopefully). Can someone confirm or correct me when I say that I though the maximum payload size one could use with the new transport package is 1466 bytes?
(That is 1470 - 4 bytes, due to the NetworkConnection header)
Haven't touched it, though if you can't find documentation to confirm it you could try sending it a byte more than that and see what happens
I already had the error. Fixed it by setting my own size limit 100 bytes lower, than what I thought I needed, so 1366. Tried 1462 at first but that also failed.
The UdpCHeader struct from the transport package looks like this:
[StructLayout(LayoutKind.Explicit)]
public unsafe struct UdpCHeader
{
public const int Length = 4;
[FieldOffset(0)] public fixed byte Data[Length];
[FieldOffset(0)] public byte Type;
[FieldOffset(1)] public byte Flags;
[FieldOffset(2)] public ushort SessionToken;
}
Basically I'm just wondering if it's my own code that's wrong or if I've missed something in the package.
Hi there ๐ is there some PUN expert here ? :p I'm currently creating a FPS and I was wondering how to manage the end of a round. I want to "reset" the Scene,reset the score and have all the player RE-instantiate.. is there a PhotonMethod for that? Thanks by advance.
There are pun users here
"experts" no clue about that
@stable cairn those field offsets seem a bit whack - not what you are asking though
nm, I see what they have going on there
I dont see any length info restrictions in that. the only length ref is just so that the unsafe fixed is sized the same as the whole struct
But it definitely consumes 4 bytes, if that is the question
Yeah that Header is what I have so far assumed to be all of the overhead added by their Transport package. But actually when I think about it the errors I'm getting are on the client, so I'm getting some data, seems to be some buffer in WinSock not having capacity for the UDP MTU, would've expected those to match the MTU
I don't know what layer this is, and if it includes any of the actual actual low level buffer stuff for UDP. I really don't ever get that deep into the transports sorry ๐ฆ
1462 is a very odd size
so that seems like its got extra padding for something
I would expect the limits to be nice even numbers
1470 is the MTU for UDP, unity's transport layer is supposed to use 4 of those. I just gave 4 extra to check if it could be some for loop going slightly too far. But assuming my packet was maxed at all times, the limit must in reality be between 1364 and 1462 based on my understanding so far. It could also be lower than 1364 if my packet wasn't maxed when it worked.
Ahh, nm then - you know way more about this than I do
Its all C# code no? Or is some of that compiled?
How far can you dig down to see whats going into that packet?
It's C#. The transport package is from unity's open-source multiplayer repository. I'm working strictly with byte arrays though. I added some size checks right before I give it over to unity's network driver, so I was expecting the exact same data on the other end, but I get internal buffer exceptions before then, and they seem to be part of WinSock which I suppose is what the transport package is using, and which I know very little about. I don't have the error message currently, as I did a workaround, but when googling I got some stuff, but no clear answers.
And the part of code that throws the error is pretty deep in some unsafe pointer stuff with a buffer that I didn't immediately find the construction of.
yeah, I'm more out of my depth there than you. I literally never go deeper than handing my byte[] to whatever net transport I am using
But I remember the error code being 10040, which I believe is specific to winsock, or at least handled by it.
Thanks for trying at least ๐ Here's the error, it also mentions the 1470 bytes.
https://support.microsoft.com/en-ca/help/225004/wsaemsgsize-error-10040-in-winsock-2-0
It may need some space for winsock junk yeah.... wish I had a clue about any of this ๐
Yeah it's pretty low level, but I think it would be nice to get it right the first time to avoid having to revisit this code part for this kind of stuff.
I assume you would just be picking a byte count for your split point for your own writer?
So seems like whatever you code for overflow... will just need that one constant to be changed?
Yeah, unless it's my own code that is flawed
I mean, you are passing it a byte[] with a size?
Well currently I'm not splitting at arbitrary points because I wanna receive whole objects
What's the write method though to the transport? I assume it is pretty simpllistic?
like Transport.buffer.Write(myByteArray, lengthInt); kind of thing?
Unity uses a DataStreamWriter, so it's more like
writer.Write(data);
_networkConnection.Send(_networkDriver, writer);
hmm... what is 'data' ?
whatever I want it to be, but in my case that's the byte[] I wanna send. And right before that I would check if it's more than my limit.
is it a specific overload for byte[] ? or is it taking object?
And why no length info??
I hope it has a write method that lets you write only the used parts of your byte?
Yeah it takes in byte[] in it's overload. The DataStreamWriter seems to also be written by Unity as part of the transport package.
So if you send it a byte[1024] but you only wrote to like 500.... how do you send that to the transport with their methods?
I think the remaining 524 would have default byte values upon initializing the array. So unless I specifically truncated unused bytes it should be valid values. Also, the length of the array should have triggered my failsafe if it was greater than my limit, even if I only used 500
hmm, that doesn't seem right.
A byte[] write should really offer a length. Making you right size it = garbage generation. There would be no way for it to know that all those zeros are useless
which cs file is the writer in?
can look at the git now
dataWriter.Write(1234); derfug
nm, thats just sample code
{
if (length < 0)
length = value.Length;
fixed (byte* p = value)
{
WriteBytes(p, length);
}
}``` They have nonalloc byte[] writes
public int Capacity you should be able to check that to see what the total size of the buffer is
and Length to see how much is currently written to
This is from the "DataStream.cs" file
/// <summary>
/// Copy byte array into the writers data buffer, up to the
/// given length or the complete size if no length (or -1) is given.
/// </summary>
/// <param name="value">Source byte array</param>
/// <param name="length">Length to copy, omit this to copy all the byte array</param>
public void Write(byte[] value, int length = -1)
{
if (length < 0)
length = value.Length;
fixed (byte* p = value)
{
WriteBytes(p, length);
}
}
yeah, just pasted that same code LOL
Oh xD
That's the one you want to use
I'm using that
oh, so you are sending the length
it looked like you werent giving it your length int
If you check the Length and Capacity of the buffer do they look like what you expected
So if I get it right, the WriteBytes method adds bytes to describe the length? Is the capacity size also added? If the only thing added is the int describing the data length, then it shouldn't have failed when I gave my limit 4 extra bytes to go on :S But at least I now have something to go on ๐ Thanks
Here's the method used to add bytes to the buffer:
public void WriteBytes(byte* data, int bytes)
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
AtomicSafetyHandle.CheckWriteAndThrow(m_Safety);
if (m_Data->length + bytes > m_Data->capacity)
throw new System.ArgumentOutOfRangeException();
#endif
UnsafeUtility.MemCpy(m_Data->buffer + m_Data->length, data, bytes);
m_Data->length += bytes;
}
wish I was less of a C# nubbin, because I never use ->
Me neither, to spoiled with all the C# lately. Didn't do enough unsafe coding yet. I do however feel like that will happen sooner rather than later now.
I think its just adding the bytes of that write to the total count
Yeah, but I'm only calling the write once, so that's why I'm expecting it to only add the 4 bytes for the length of the bytes
You can check the length value before and after your write and see if it all adds up
debug Length and Capacity at each step
Yeah I'll have to do some research and some debugging. This class has some documentation too that may help.
You aren't exceeding that writer though, that would give a different error
But I'll look at it once I have a context where it would fail. Yeah as far as I know I'm getting all the data, so nothing from the sending side is failing here. Error happens on the receiving end, so perhaps I'm accidentally triggering IP segmentations, thus getting a combined UDP package bigger than the MTU
hmm, yeah tricky to debug that when it happens in the ether
-> is basically . in unsafe in this context
Yeah I've done a little C++, but that was 10 years ago.
In case anyone encounters the same issue - Here's the detail I missed in com.unity.transport's code:
/// <summary>
/// Default NetworkParameter Constants.
/// </summary>
public struct NetworkParameterConstants
{
/// <summary>The default size of the event queue.</summary>
public const int InitialEventQueueSize = 100;
public const int InvalidConnectionId = -1;
/// <summary>
/// The default size of the DataStreamWriter. This value can be overridden using the <see cref="NetworkConfigParameter"/>.
/// </summary>
public const int DriverDataStreamSize = 64 * 1024;
/// <summary>The default connection timeout value. This value can be overridden using the <see cref="NetworkConfigParameter"/></summary>
public const int ConnectTimeoutMS = 1000;
/// <summary>The default max connection attempts value. This value can be overridden using the <see cref="NetworkConfigParameter"/></summary>
public const int MaxConnectAttempts = 60;
/// <summary>The default disconnect timeout attempts value. This value can be overridden using the <see cref="NetworkConfigParameter"/></summary>
public const int DisconnectTimeoutMS = 30 * 1000;
public const int MTU = 1400;
}
In short, the default MTU value set when using default NetworkParams to initiate the BasicNetworkDriver is set to 1400.
Great, sounds like you solved it @stable cairn
@stable cairn and what is an option? to extend MTU?
I assume they picked 1400 as a safe value for some reason
https://en.wikipedia.org/wiki/Maximum_transmission_unit
It probably is just a number below the cases they anticipate
In computer networking, the maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single network layer transaction. The MTU relates to, but is not identical to the maximum frame size that can be transported on the da...
Yeah, that's a very common thing to do
Unless you really plan to overstuff your packets, probably best to leave it there
But you can insert custom NetworkParameters to the NetworkDriver when initiating it. I think the MTU may be changed that way, although I'm not sure. At least most of those can be overridden.
Then again, since the transport package is open-sourced I could change it if I wanted to, but I'm content enough just understanding how it works. I don't have a current urgency to maximize my networking capacity.
hm. so if you want to make it stable i think a good solution is to send fixed sized packets. like 1kb. there are several reasons for it:
- you will have "extra" space below mtu for custom headers to define what kind of data you're delivering and some extras
- you will get a stable fixed load over network
also in this case you'll be able to use fixed sized 1kb buffer for transported data, so it'll be easy to fit chunks in it before sent (like using offsets and so)
the 2nd also is an ability to batch small packets that need to be sent between sendrate steps, it will reduce net load by using single UDP header per several packets (26 bytes)
i've did this several years ago for webplayer and it works pretty good in production
I would def not do that
99% of my networking work is in trimming every bit out of packets
sticking a bunch of padding back on them seems a bit... counter to that?
I can see fixed being fine in a game where the states are always the same size but generally the server outgoing stream would get pretty expensive wasting that much data
All modern networking you are buffering updates on the clients and server, and they will absorb any jitter anyway
Not saying it wouldn't work for some cases, just that as a general practice that seems like a bad idea
the main concern is to keep packet size under MTU and have a fixed sized buffer below it's value . you don't need to send trailing zeroes actually, in any way you know actual size of data before sending and can also put it in a custom packet header
then read on other size
you just use the Write(yourByteArray, length) call for that yeah
but that would be sending variable sizes, which I would recommend
The transport adds the header and you just write to it with a standard serialization write method, he was just hitting a weird arbitrary number or bytes written that couldn't get through
@stable cairn That's a bit odd that the writer let you write past 1400, and that it isn't aware of the that const?
it'll be weird if writer will NOT let you to write data bigger than MTU
yeah, that was why it was strange... he would write and send it, and it would break on the receiving end
as i see he sends a packet size
2k for example, and got only 1400 cause packet were fragmented, and then tried to read 2k
EOF (end of stream actually)
@untold plume Yeah I got errorcode 10040 from WinSock on the clientside, which was something about a buffer not having capacity for the data, but it was within the internals of com.unity.transport. Either way when you mention "extra space" for custom headers etc, that's handled on a higher layer in my model. So the number I was looking for is going to be the upper limit before the data must either be segmented or reduced in size, with all necessary custom data included in that number. The perfectionist in me would like to not limit the system out of lack of knowledge and guesswork basically.
I think that is mostly about rolling your own RUDP for fragmented packets
RUDP is next article ๐
Thanks! This is going to help future me a lot ๐
Next article is relaible order not really RUDP
fragments don't need to be ordered
but for what the article is talking about its for when they have to get through
rather than usual UDP... fire and forget
I'll need all of the above unless Unity implements them as part of transport
does the MP transport not have a reliable channel opt?
gafferongames is a good point to start as for me
okay
all great stuff though, I always give his page as a reference to others
The new transport package is very barebone currently, I don't think it has anything. Well it does do multiple attempts at establishing connections, but for data I don't think it cares
hmm, I would expect them to add some RUDP handling if its not there already
since all of the basic libs do that
If it isnt going to, I would just stick with like a LiteNetLib in the meantime
LiteNetLib is pretty good
@stray scroll no idea on your issue but you can put your links like <https://thing> and it will not fill half the screen with the link previews ๐
Will think of that to the next time^^
it's no big deal, just thought to mention it (you can also edit the original message, add those <> and it will remove the previews)
Yeah, I just realized I might've phrased it bad anyways : )
So could anyone help me understand what the meaning of
if (!m_Connections[i].IsCreated)
Assert.IsTrue(true);
Means in context, and what it does here?
https://github.com/Unity-Technologies/multiplayer/blob/master/com.unity.transport/Documentation/samples/serverbehaviour.cs.md
https://github.com/Unity-Technologies/multiplayer/blob/master/com.unity.transport/Documentation/samples/jobifiedserverbehaviour.cs.md
Well, Assert.IsTrue(true) won't do anything I believe, seems more like a placeholder to be replaced with proper handling. The if check is just checking if the connection hasn't been established properly, so I would imagine that you'd want to skip checking events for it? Perhaps using a continue instead of the asser... I may have missed something.
Assert is a special kind of failsafe check that will give you error prints if the assertions give unexpected values, and if I understand correctly they will be skipped during compiling, so it's like a good way to print things that go wrong without worrying that your end users will see all the errors meant for dev's eyes only.
Someone correct.me if I'm wrong. But In the example the Assert is "making sure that true is true".
Hmm, that's what I thought as well. : ) Thanks anyway.
Hello community, I'm currently writing a tutorial about how making network games using DarkRift2. Take a look on my last article here : http://materiagame.com/2019/02/15/darkrift-2-tutorial-for-unity-3d-part-8-darkrift-2-messages-concepts
Feel free to ask me questions if you need some help
Hey @sly shard why did you decide to use TCP for reliablity and not RUDP with difirent forms of reliablity, for instance out of order but reliable etc?
woulden't that be much better
@sand lotus I'm not the dรฉvelopper of the library
okay.
Darkrift also has no sequencing and is open for replay attacks
Personally I would recomend https://github.com/nxrighthere/ENet-CSharp
it is full UDP based
I think DarkRift is supposed to be an alternative if you want to get your hands dirty and as barebone as it gets to have a minimal overhead, so its basically just connection wrapped sockets?
but it performs worse than enet
Seems like it has a higher CPU cost at a lower Bandwidth
https://github.com/nxrighthere/BenchmarkNet/wiki/Benchmark-Results
It has lower bandwith because it includes no sequencing
Yeah, I fully understand its not a fair comparison x) Would be nice to know what all includes and what not.
Last article available right here for DarkRift2 : http://materiagame.com/2019/02/16/darkrift-2-tutorial-for-unity-3d-part-9-send-spawn-messages-to-clients
Any network library recommendations?
@barren fractal Several - depends what kind of game you're making.
Give me a rundown on them all
I hear Proton
and I've attempted to use LiteNetLib at one point, haven't really done any Unity3D work for a while
Unet is Deprecated, Mirror is the replacement. Also there's DarkRift, Forge, MLAPI, and Photon Bolt
Is Mirror the Google Cloud partnership one?
no - Unity is a year away from having much to show there, and they're not doing a replacement HLAPI
So.. what is Mirror?
Mirror took UNet, forked it, fixed all the crap, made a bunch of enhancements.
Interesting
multiple transports, all source
Are all these except photon, open source?
has nearly all the same outward facing classes and API as UNet, so it's easy to migrate...there's a migration tool for existing projects, and 3rd party assets built for UNet generally work without too much trouble.
I never really touched Unet, when I got interested in making a multiplayer project, Unet was already announced for being depreciated.
DarkRift I think is $100 one time for the source - can't remember
don't bet the farm on that factoid - check for y'self on that
Project I have in mind is an Android game that is locally hosted
so, someone makes a "lobby" and people connect to it via "ip"
Probably all of them can do that
OpenNAT
OpenNAT? Is that a library or feature?
open source NAT library on GitHub
and yes - anything with Photon has a CCU $$
It's probably easier to use a service like GameLift, Steam or some such to get you past the NAT / Relay issue
Will I be able to do Peer to Peer with Mirror? Such as LAN, or will it connect to some external server?
Doesn't Photon have an external server that forwards users to be peer to peer
the time and effort you'll spend making and supporting your own will be worse than some nominal fee to a service
they do
NAT isn't 100% assured to work, especially with mobile, so you'll end up relaying as a fallback
What about LAN only?
sure that'll work
Will it still force a relay?
make a server on a PC and have all the phones connect to it
not if they're on the LAN wifi
it's the cellular that is flakey
The game is more of a party game, so it could work with LAN.
It's a "spyfall" like game
What about options for dedicated servers like if I did something with AWS / Azure / GCP?
That's what all of these solutions are really built for
They can be used for small party games, but they're designed to be headless servers on a VPS
Give Mirror a look https://assetstore.unity.com/packages/tools/network/mirror-129321
So far Mirror is sounding the most interesting to me
I think pun2 was 100 and pun was 20
The question is really if you want to write your own higher level parts
or you want to rely on some middleware
the lower level stuff, the transport
there are plenty of options around
that take care of reliable UDP for instance
their free, their opensource, they work well
if you need high level API stuff you can look at mirror
but make sure to switch our their default TCP transport, its horseshit
not because its TCP, but because of how that is implemented
anyway mirror is basically just the unity HLAPI and it's having some features removed and a bunch of bug fixes
if the HLAPI/mirror is too high level and too generic for your project you can also look at the MLAPI which is on github too
or you can just roll your own higher level code which what most people are doing
if you are unable to roll your own things you can choose to go for photon or something, there is also smartfoxserver and I believe partialOS
but you will have to take their expensive CCU prices
SpatialOS not partialOS
right.
You are allowed small deployments for testing, anything more you need a quote; based on multiple deployments or amount of users
I don't want to use anything CCU related
I think Mirror is the best High level I've been browsing, especially because I have no experience in networking
Several months ago I was suggested LiteNetLib but it feels like I have to reverse engineer that library to just use it.
I'm working on a legacy project that is using unity HLAPI. We have held objects that become parented to the player object. Anyone know if there's a callback method I can use to deparent the object when a player disconnects, before the server destroys the player object?
@slow bay See if you have OnServerDisconnect available
@barren fractal Forge is an option too
interestingly enough I dont remember Mirror being one of the big hitters when I last did networking
it looks new.
- [SyncVar]s and SyncLists are used to automatically synchronize state.
that looks nice
Seems to be pretty to the point if you can manage your own matchmaking.
//f
I just need to start finishing projects.
So I'm working on a game and I want to use steams p2p stuff, I have Facepunch.Steamworks which let's me create lobbies and send p2p data but I don't know the best way to seralize and send it
Bit pack into a byte stream and send that?
That's the end of the line for most networking... if you have access to the byte[] stream... you serialize to and from that no matter the transport.
https://assetstore.unity.com/packages/tools/network/transform-crusher-free-version-117313 If that part of serialization you are asking about, I have a free asset you are welcome to use for bitpacking. It has a byte[] extension class in it with a bunch of writer/readers. @serene hornet
I'd say your package would work too.
The basic concept would be BitConverter.GetBytes(i)
just take whatever you want, break it into components, like position x as either a float or an int, get the bytes for that, and send the bytes, then do the opposite on the other side. Thus the basic concepts of how to do networking in any instance
Yup, what you do in side of the serialize desrialize methods is totally up to how nutty you want to get with packing. You mentioned bitpacking (as opposed to bytepacking) so as just offering up my bitpackers if he wants to avoid getting his hands dirty in bitshifting.
Or just keep everything in even bytes. Not nearly as compressed but fine for development
@paper stone I tried using LiteNetLib but it feels like I need to reverse engineer it to know how to use it.
Well - I'm using it only for connection + data transfer using 3 QoS channels. I'm not going deep into it's core because that's why I'm using framework nor my own network implementation. ๐
@barren fractal
You can access source code though
its open-source
I know, I have it on a project
All I managed was making my phone connect with my computer
But trying to figure out how to get packets to send between clients is a major shrug from me.
Check this out
The idea is registering packets on both sides and communicate by sending byte arrays (the first data type is packet id and can be byte, short etc.)
whenever server/client send it to other side it unpacks byte array and take out bytes chunk by chunk so you can get info like array.GetByte() and turn it into id
Anyone know of a good source for getting a full tcp server going? Not just connectivity, can easily do that, mean practices for handling events and for packet encryption/decryption; pushing the correct packet IDs into the correct methods (send a vector over the server for example, dont want it to get confused between the three position/rotation/scale).
Ideally I think i need to find something that creates a copy of client1 on client2 and when client1 does something it simulates it for client2 rather than sending values
books are also accepted
i really need to use proxy in my game and i'm currently using 2018.3 and network.useproxy is deprecated. then i see mirror asset but that didn't contain this api on it.
so any solution for using vpn and proxy or anything like that in unity?
@tidal shard That would be at transport level, not HLAPI level, in Mirror. The transports would have to reimplement that.
^^
@gray pond thank you for reply but could you please be a little more clear it has nothing about proxy in transport
@tidal shard In UNet Networking everything was jammed together and the only transport was UDP. In Mirror, we've separated the transports out to be independent, and interchangeable, components that handle all the connectivity and msg traffic, and that's where I think proxy-related code would be implemented. Your original question above is what first brought this to our attention, honestly, so we'd need to dig into it a bit further. I don't yet know if all transports would have proxy stuff or not.
It is possible a nodejs websocket server is more performent than for example WebSocketSharp in C# server?
trying to find decent Websocket solution in C# for multiplayer game like agar.io that will have decent performance
Can someone tell me the name of Unityโs network namespace? I have done some research but everything seems to be deprecated or removed.
@native fossil It was Networking - gone
it was recently depreciated yes
there's a new system in development to replace it
The netcode is using Unityโs new transport layer, which was just released in preview.
is the only example of using it i know of
and where they announced the depreciation
it's going to continue to be supported for awhile
so you could still use it even though it's depreciated
approx. 2-3 years from now
but i know next to nothing about networking so there may be a lot i don't know about
run and never look back
Another (small example/the og repo)
https://github.com/Unity-Technologies/multiplayer
a repo not touched for 4 months
And a bad one too
This will not scale at all
maybe workable for 10 player games
I'm pretty sure this is even worse than LLAPI/HLAPI Unity made before
the samples are horrible
a simple Ping pong shouldent take thousands of lines of code over 10 files
and the transport itself is a wrap around udp sockets
without anything really
no reliablity channel even
so what's the point of that
Its a first view of the llapi and how to use it, from what I see same used in the FPS demo. Not including the packet there are 3 scripts needed for the ping pong(client, server,gui), so from a user perspective not a thousands line of code? And the transport layer is connection oriented UDP sockets with no reliability that are compatible with the ECS. Sure it would be nice with some RUDP, but it can be implemented in many ways and that in regards to the game, and who uses TCP anyway ๐
Nobody should be using TCP for a game
just to update a bit about UNet
from https://forum.unity.com/threads/unet-deprecation-thread.543501/```
Update 2/14/19
We've been following user feedback, and took some time to discuss internally; we want to share a few updates:
-
LLAPI guaranteed in 2019 LTS build - due to demand for more time to transition and give the new transport more time to mature, we've decided to guarantee that the LLAPI will remain in the engine in the 2019 LTS build at the end of this year, and therefore will be supported with critical fixes in that build until Spring 2022. This is a 1-year extension from the original plan, and we will soon update the original blog post to reflect this change.
-
Plan of Intent for Networking - the networking team has published their current priorities and focus areas to the public git repo - it's their goal to keep this up-to-date with each of the projects we're currently working on. We've been seeing solid progress internally, and we're hopeful that some of the work-in-progress items listed in Github will be in the hands of the community soon.
-
DOTS-compatible - the new networking stack will work with ECS, Job System (for multi-threading), and Burst Compiler to reach the best possible performance and scale. AND, it does not require you to use DOTS for everything, most of your game can still be written in classic unity if you prefer that.
-
HLAPI support LLAPI and new transport - HLAPI will be released soon as a full-source package, and will be supported according to 2018LTS terms, so critical fixes will be provided until Spring 2021. This has not changed from the original plan. For clarity, The HLAPI will support LLAPI and the new transport (once it reaches a sufficient feature set) throughout this transition period. We feel confident that before 2021, the new networking stack will be a much more performant solution than the HLAPI, and we strongly recommend developers move over by this date.```
so in other words, you are not in a hurry to move out of UNet if you like it (many don't)
"the networking team has published their current priorities and focus areas to the public git repo" <- where is this?
oh snap
there was a link in the original post: https://github.com/Unity-Technologies/multiplayer/projects/1
depends on the game for the protocol
Just ditch that stuff and simply put it in a public repo
even if it doesent run in the current released unity build
get code in our hands so we can comment on it
put in issues
and help the development
like the scriptable render pipelines
or the post processing stack
I dunno, people shit on Unity for even doing preview releases ๐
some people have really hard time grasping concept of wip
modern devs *sigh
but I don't really disagree, I love more transparent development
especially since they are doing it for us, the engine users
right.
there's really not all that much reasons to hide what they are working on
I hate being in this dilemma if I should wait for them to complete their features or build something that works myself(but probably not as good as they will do it). I don't want to halt my gameplan, but I don't want to "waste" hours if I will just replace and throw it away either.
Sure, but I want to use ECS, so something that would neatly integrate with that and be replaceable without too much of a hazard ^^
nothing with ecs will be easy but there is somebody that did it
I don't think it's bad they release a preview, but immediately depreciating the current solution leaves devs trying to write a networking game in Limbo
they shouldn't start depreciating anything until the new solution is up and working.
In general yes. But unet wasnt a great solution for most to begin with
so I've heard many say heh
Use other existing product like Photon is probably the best option.
Does anyone know if the PhotonNetwork.LoadLevel() do anything besides telling the clients in the room to load a certain scene? some behined-the-scenes-magic?
Or can it be replaced by an RPC-instruction to tell the clients to load a scene with the SceneManager.LoadScene()
I know Unet is going to change. Anyone knows if the Network Transport Layer API will also get changed? https://docs.unity3d.com/Manual/UNetUsingTransport.html
yes its kind of depricated right now
@coarse sleet
https://github.com/Unity-Technologies/multiplayer
What I don't get is why there is a package that still get updates with the old networking
I must say, I would have appreciated if the guys working at the FPS sample would've commented their code a bit better ๐
@weak plinth there is probably callback called
Hey, I'm looking for an asset which is similar to the Master Server Framework. Master Server Framework is out of date and crashes. My goal is that the player can create rooms where other players can join.
@weak plinth it can be replaced with a rpc
The only noteworthy difference is that I believe with photon load level other player scenes will update if automatically sync scene is true
Which even then iirc that only applies to on connect.
posted about FPS Sample update here: https://forum.unity.com/threads/fps-sample-0-3-0-now-available.636883/
hey, can somebody please tell me how i use any sort of VPN , Proxy or best option change DNS for My android game I've been desperately looking for something and even tried using java sources but didn't get anything
its still in preview
but the FPS Sample uses it
and i guess this is the repository/documentation?
hey, oh cool i didn't know there was a preview thx
best protocol that's possible to use with unity to open a socket for a server side Python script that talks with the database? latency isn't a gmaechanger, but I'm thinking 50ms ping is too high? I read above TCP is bad for games which is what I had been trying to set up for localhost testing
"TCP is bad for games" is a nonsense blanket statement of absolute. It's challenging for twitch FPS. It's fine for a lot of other types of games.
@gray pond ok, cool, I have my answer then, I just need a localhopst based mockup as a placeholder to structure my framwork around anyway, thank!
Unity has UnityWebRequest if all you need to do is hit a web service
you can then write the web service in anything you like
it's HTTP(S) / REST
That's not deprecated - it's what asset bundles use
I'm going to put my SQL DB and python scripts on a linux cluster at somepoint, not sure if http will suffice
web service will be a lot easier to load balance across a cluster than a socket
socket is connect and stay - web service is request-response-done
xml isn't my thing, and I need the listen stream open the whole time, going to be reading writing buffers both ways
php, cpanel?
could be JSON, could be raw text, could be binary etc.
gotcha
the payload I mean
http=80, https = 443
telnet still exist lol?
but if you need a connection to persist so you can sustain bi-directional data over time (minutes or more) then you need a socket, not a web service
yea, I can open sockets with python, by I don't know the ins and outs of validation/certificates and how unity handles all that
on the .Net end
outside of UnityWebRequest (which hits a web service, not a socket) Unity doesn't anymore
that answers my question..
what about a plugin?
a dll and seperate process?
that's a pretty nastly limitation
what's the player side of the game like?
Not going to have access to 90% of the data on the client
maybe, idk, I need to figure this out before I develop further
I mean what the play style...turn-based card, rpg... ?
so what are you going to do for server-side collisons, physics, navmesh, etc.?
not much physics involved, just use EVE's bounce if your kinda cloe approach
and the meshes are 2d "cutouts" in a 3d world
just orbitabl mechanics at a basic level and isTargetted = true; kinda stuff
maybe even forget collision altogether and leave the shaderqueue to decides who's in front
I think you're going to quickly find you need Unity on the server side unless you're going full client-auth (cheat mode)
I just don't want to waste access to a server I can rent for free that hosted 1000 minecraft servers in the past
simple game, something like this, adding the simulated zed axis now https://cdn.discordapp.com/attachments/493511468134694912/550759016259911681/2019-02-27_16-40-30.mp4
I'll have to find a way to open a socket, there has to be some solution besides WWW
You could start with DarkRift2 that runs as a stand alone on server (no unity) but if you think you're going to want Unity goodies at all on the server side that's going to be a lot of work compared to something like Mirror.
I don't need unity on server side
k, then look up DarkRift2
Hello, I know very littlie of network coding but I am trying to update some old code that is using the old WWW, what is the new way to get www.text in UnityWebRequest or is there something I should be doing differently.
hey, i have no experience on networking in unity and i have to implement Realtime multiplayer in short time.
so i have to choose between Mirror and Forge Networking Remastered which one you recommend for someone like me?
Photon
Photon is the easiest to learn but expensive in the end if you have regular players. If you use photon make sure you use photon bolt
well yes its expensive but the dude sais he has no experience and has to build realtime multiplayer in short time
well there are your options
Hey, is there any library that you guys use for web socket connection in your unity games? I am using WebSocketSharp for a turn-base online game in unity and it has major issues in android devices change network detection.
@split rapids we use a slightly modified Ninja.Websockets version for Mirror
Is there anyone her who has tried to use CorgiEngine together with Photon?
I have an idea for a project that would involve displaying either a user's personal Google Photos
OR
the results of a public search using Google Image Search.
Can anyone tell me
a) Is either approach possible in Unity?
and
b) What is the best strategy for displaying image data pulled from the web inside Unity?
you can use rest/httprequest for google drive things, you do need an access token though so you would have to find out how to get through that
(User sign in, you need to contact google for the access key, find *.png/bmp/jpg/jpeg etc)
Any tips for a dedicated server setup ?
you mean hardware?
For a game set in space, I figured rigidbody would be my best bet with all of the physics around space and I needed some freedom that the CC doesn't really offer
How would I go replicating players with a rigidbody?
with server auth? Or client pos auth? @glass bobcat
@jade glacier server auth would be better but not critical
It's a coop survival game
Nothing competitive but I might add other modes
with server auth its a bit challenging with phsyx, since you don't control the simulation
F
People deal with it by allowing some amount of error, because its hard to push corrections from the server back onto the owner
For client position authority, you just send the transform to the server, using whatever form of compression you see fit, and with some form of buffering to smooth out jitter
https://assetstore.unity.com/packages/tools/network/network-sync-transform-nst-98453
The sample scene in my asset does that, if you want to see an RB synced
server auth with RBs isn't a lot of fun. with 2018.3 though they changed phsyics
so you can resimulate, but its still a bunch of extra steps to do that
Yeah
I could use CC but for a space game with 0 gravity in some cases, players floating around etc it might not be as good/as easy to use
Yeah, look at my demo scene
why on earth you would have server auth on co-op?
that's like asking for trouble for all the wrong reasons
Nothing competitive but I might add other modes
its floaty quaternion based dudes with RB forces being synced.
client auth has downsides, but for a coop it very well may be worth going that direction. I would only recommend server auth if you are looking to either become a networking guru, or if your game is really going to need that kind of anti-cheat and fairness built in
server auth is one thing
You can server auth some stuff
doing that for physics is total another level difficulty
like you can server auth to check on hitscan claims
and tracking score and such
but the movement as server auth really needs you to manhandle the simulation, more than you probably want
https://assetstore.unity.com/packages/tools/network/network-sync-transform-nst-98453
This literally exists for what you are describing. Not trying to sell you on it, but the demo scene will give you an idea of how client movement authority feels in a real usage
How would you do if you wanted to go from spectator to joinning a team ?
do you destroy the spectator and instaciate a new player but you have to pass the id to the new player prefab
or do you just change the player inside the gameobject
Unet?
ty for the tips @jade glacier
helped I hope
hi guys, i have a question i'am searching in the unity Manual when i look for the Network manager Section, there is only written Obsolete but no link whatsoever to the new Manual.
๐ฉ
It's now on package manager instead
Unity's removed HLAPI from newer versions and provides it here for people who still want to use it + newer unity
@compact bramble hey very cool thanks!
@steep wigeon would be cool if you write such things into the manual instead of just obsolete ๐
Everything's still deprecated in the package, isn't it? There's no HLAPI planned for the new ECS thing Unity is making. They've just tossed this out for legacy.
Their new networking will be ready by then, it's being developed alongside
one doesn't advance without the other
they have it implemented in their fps sample project, partially as hybrid and low level transport. the rest is coming, so they'd love me to keep saying
the reality is I have no idea the progress of it.
but that's the plan
in any case I'm not fussed, photon is always there and @graceful zephyr always grimly looking down from his throne of dead modems
I think the new networking is going to be even worse than HLAPI
I have 0 trust in unity to do it right
their current project they put up is horrible
and their FPS example is also very badly implemented
I think it will be the end for unity in the topic of networking
the average dev will go to unreal because of the lacking multiplayer on Unity.
Which networking solution would be recommended for a game of for example 4 people without a dedicated server, so peer to peer?
for such low player numbers anything can work
choose any of the 297982 options that you like the most
The reason why I'm asking @sand lotus is because I don't really know all the 5239723 options. The only one I've heard of is Mirror. That's why I'm asking in here, since the people in here have more knowledge about it than me ๐
For small project like your making mirror is probably OK
It's not really very performant but who cares at 4 players
just don't use their standard TCP transport, switch it to some UDP variant, I believe they offer two
Are there any with a mix of both TCP and UDP?
Why would you want that?
In case I've packets which are important, and some which I simply don't care about.
So it's less performant.
In a game situation you should never want TCP, let alone a mix of TCP and UDP, there are plenty of good Reliable UDP libraries around, that have the option to send things in reliable channels (they will always arrive, data gets resend when lost) and unreliable channels ( data lost is lost)
Mirror itself is also having some UDP options that both implement reliable UDP
if you mix TCP with UDP things start to break fast, TCP will make UDP pretty much die.
But why does TCP exist if you've reliable UDP lol
Because some people have no option to use UDP, for instance their making browser games
Or TCP simply works for their slow paced turn based games
Alright!
TCP is supposedly easy, because you don't care you send something and it will arrive for sure, and in the right order
sounds awesome
the problem is if something is lost, the data is resend
but maybe some data you dont care about
Lets say your sending 20 movement updates per second
if movement update 11 is lost
12 13 14 15 16 get ignored
till 11 is finally resend
then all are pushed to the game
but by then the information in update 11 is useless
and 16 arrived super late
I see the problem yeah.
But mirror is probably going to be the best one for me?
(The UDP variant)
There are many options, if you want something really simple for 4 players that is fine
if you want to get a bit more dirty you can try implementing any of the transports yourself directly
You can also choose to go with the solutions around
like Photon etc
if you don't want to bother about a lot of things
but that can cost money
"can", what's the point you've to pay?
100 CCU i think
And mirror, does that have paid features?
no
it's just a fork of the Unity HLAPI
open source project
missing some features from HLAPI
And are any of those missing feature's important ones?
depends your use case
I think they removed the whole lobby system but recently brought it back
more than that I'm not sure.
What kind of game your building anyway
except 4 players
I just simply want to test with some small scale networking solutions, not planning on doing really anything with it. ๐
Just expanding my knowledge ๐
alright
if you want to really learn something you can just use mirror to get things working
and if you want to learn more about actual networking
serializing data and so on
you could do code it yourself
Building my own networking solution on a low level API you mean?
Only one I've ever seen was something called lidgren
Lidgren should be depricated
the one i linked is the fastest one around right now
but its having unmanaged code
if you want to stay in managed code
you could use this one
Sorry, I don't quite get what you mean with "unmanaged code".
Unmanaged code is non C# code
enet is simply C code
so it's a native binary you interop with C#
I think I'm going to play around with LiteNetLib a bit. :3
Thanks for the help โค
@sand lotus One question though, why shouldn't I use a precompiled .DLL? I also don't really know how to include the library sources in Unity xd Always use library sources instead of precompiled DLL files..
Unity has to just use the source
so don't use C# dll's
unless there is no other option
Ofc you can use native Dll's like in enet.
You can use C# dll's but sometimes that can be troublesome
But how would I let Unity use the source?
Copy the files into the project
Just that?
under assets make a folder drag it in done
Seems to work!
It works >:) https://gyazo.com/a486dab23149eb18ed0ff662e702dd34
gj
I'm having a bit of a struggle. I have set up a simple tcp client and tcp listener (more or less indentical from the examples in https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.tcpclient?view=netframework-4.7.2 and https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.tcplistener?view=netframework-4.7.2)
Running the server through the Unity Editor, clients using a built instance are rarely are able to find and connect to the server. When the server is running on a built instance and client in either the Unity Edtior, or a built instance, everything works fine no problem.
Does anyone have any experience with this issue? I'd like to be able to run the server through Unity to have better debug capabilities
@sand lotus Do you've by any chance an example for the NetPacketProcessor? Since I'm really confused on how it works, and can't quite figure it out.
i never worked with litenetlib
i did make my own packet processing algoritms though
but can't really show you something
Seems like I'll have to use something else then, since the examples from the person them self aren't finished and the wiki really lacks information ๐
most lower level libs don't have much documentation
you just have to get it to work ๐
with your own code
i thought your point was to learn something
That's the problem. I can't get it too work, even with the most spaghetti code ever.
And yes, it's still to learn something.
But how am I suppose to learn something when there are no tutorials, barely any documentation and half finished examples?
i saw that on the git
Yes, and I followed that.
And it ended up to even be able to send the packets with a big mess of code, and second of all still doesn't receive the packet.
you folowed the unity example right
It's not finished.
I see
I haven't checked the contents of the lib too much
I only saw people use the transport to great success
If you want something that is more higher level
poking at transports is not the way
maybe https://forum.unity.com/threads/mlapi-hlapi-replacement.511277/ this is more for you
I'll take a look at that ๐
It has examples a wiki and everything
Hey, I'm trying to talk with an API but am having some trouble. The code that worked before was:
private string url = "http://api.site.com/api.php/function"
IEnumerator CallApi() {
WWWForm API = new WWWForm();
API.AddField("name", "value");
WWW APIReturn = new WWW(url, API);
yield return APIReturn;
if(!string.IsNullOrEmpty(APIReturn.error)) {
Debug.Log("ERROR: " + APIReturn.error);
} else {
Debug.Log(APIReturn.text);
//DO STUFF WITH RETURN VALUES
}
}
After installing a SSL certificate (and changing the url to https) however this stopped working
I now get the following error: "SQL server does not exist or access denied"
Looking at the FPSSample server side, is there any other reason than possibly having multiple Receive and Send over clumped Ticks for not using FixedUpdate instead of their own loop?
I suppose because fixedupdate is not really reliable to get anything at a certain pace
if the server slows down it could run multiple fixed updates after eachother
because it can never miss one it HAS to execute them
even if you run lets say your fixed update at 30
and your server fps at 30
sometimes a frame happens without fixed update
and then next frame will have two fixed updat runs
it's just not a good way to handle that stuff.
Hmm, that's true. So in that case you would try to tweak the normal Update rate anyway to try to keep fixedUpdates spread out.
Which is presumably harder since you don't have access to the timers...
So the best thing to do is just run your frames at a set rate
Now I think I'm going outside the realm of networking, but I'm trying to find a way to run the ComponentSystems "manually" in that loop. Like World.RunSystems();, and the closest I've found is that it is tied to PlayerLoopSystem, but then you get back to using your own Update method. :/ I need some more code exposed x)
or decouple you're game from your networking side and leave it in it a dedicated thread?
For the server side?
yeah
there is also some info here https://gafferongames.com/post/fix_your_timestep/
This is pretty much how fixed update works
it's very based on physics
Yeah, I've read that.
but maybe for networking you don't want that
Personally I run the game at server side at set framerate (32) and hopefully the server processes everything in that time (31,25ms)
And done it in my old game engine, but this question was more aimed at ECS than networking ๐ Still don't get what you would get out of splitting the send/recv from tick on the server.
ah
Thanks for the help : )
@sand lotus Little update, Iโve given LiteNetLib another chance and it now works! ๐
So question, how would I go about making pathfinding on the server side?
How is the server suppose to know how the map looks like?
export navmesh ยฏ_(ใ)_/ยฏ
whatโs a reliable method to securely send POST requests to a server from Unity?
you still have access to the actual WebRequest class as well
@gray pond @vernal remnant got it. If im uploading a mic recording, would you recommend base64 encoding it and sending it in the metadata? Or a different strategy?
@tender falcon I'm off to bed, but see if this helps https://docs.unity3d.com/Manual/UnityWebRequest-UploadingRawData.html
Would search around, things like NAudio or manually using winmm.dll come to mind... Or find other sources that assist with it; I think they mostly send wav bytes... Create audio, save, send to server; if success delete saved file, or attempt to send again... Receive bytes, create wav, play file, delete file
or you could probably just stream bytes out and play it on the receiver
only problem is that you wont have any fallback if there is packet loss (depending how important the voice clip is)
And you will still need to process chunks, because some people just dont shut up
Question, how do games normally connect to servers on other IP's without port forwarding? The Forest does this for example, but I'm wondering how.
And with server I mean a client which is a server / client ๐
Forest probably uses 7777, common game port and is usually open
Probably through relay servers
@void burrow forest uses steamworks as the middleman
So steam itself takes care of that
Yeah so relay
They use photon bolt so technically they could use photon cloud too, but pretty sure they used the steamworks setup (it is not offered automatically anymore as it doesnt help them to sell ccu plans)
@void burrow @vital hawk Either way that comes out to relays. steamworks and photon cloud are both relays
@vital hawk i've seen The Forest on Made with Photon page
^^
does somebody knows a good solution to make a server authoritative dedicated server ?
Depends on how your game works and what your server needs to be able to do @solar garden
Im aiming to do the same thing as counter-strike or the source engine in general i tried photon bolt and other Unet tutorials but it seems either way you still need to go through a cloud
Dedicated server implies you intend to host it someplace like GameLift, PlayFab, Vultr, Digital Ocean, etc.
but they are just servers or they are more than that ? i mean i could host my game on a home server ?
Some service that will either run a perpetual world non-stop or will spawn instances as needed for matches
hosting at home is problematic because of NAT
There are solutions but they don't work 100% so you end up needing an actual public server as a relay, which will add latency, so you end up putting it on a public server anyway
Some services have free tiers where you can run your server with a limited CCU and bandwidth for free or very cheap while you're doing development.
and for the game logic part what can be a good solution to build the authoritative setup while also being able to host on whatever Service i want ?
That's back to the original question of what the server needs to be capable of. A turn-based card game doesn't need what a WoW game does
Physics? Collisions? Raycasting? NavMesh?
can it have all ? haha
probably all of that - Check out Mirror https://assetstore.unity.com/packages/tools/network/mirror-129321
it says that it was built for MMO's, could it work with fps ?
yup
well i'll give it a shot thank you
There's a Chat link there that takes you to our Discord - we're there when you need help
great ! i'll be sure to ask thx
sounds like you guys are talking about Noble Connect
oh I was looking at some junk way in the past...disregard
@gray pond Mirror uses TCP ??
@solar garden Mirror has 5 transports to chose from: TCP, UDP (2), Steam, and WebGL
steam too ?
What does it means like it is using the steam cloud ?
yup
didn't even know it was possible this mean that you can get steam id's for the player ?
oh i didn't even knew
.3 also got us c#7
Mixed reviews - depends who you ask (nested prefabs)
aha ok
oh there is a liteNetLib implementation too this is good i wanted to use it but it lacks documentation
i dont understand why you have to open your prefabs instead of just modifing like this
this is off-topic for networking
mirror supports physics too right ?
At least it'll stop occasionally corrupting your scene when modifying a prefab
true just making sure ๐
that said, making physics sync right over network isn't for the feint of heart
regardless of what you're using
prediction, replay, interpolation, buffering, etc.
does it matter in a authoritative setup ?
i can see that it has been two weeks and i still didn't started ๐
one of the better articles on the subject http://www.codersblock.org/blog/client-side-prediction-in-unity-2018
Everyone wants to make a full physics character controller over network and then they find out just how hard that is
i thought it was as simple as to make clients kinematic and sending their velocity from the server
and you found out it isn't
if you're going to make them kinematic, than there's not much point in doing rigidbody physics
may as well do a regular character controller...much easier
no but their velocity is set by the server
read the article - it covers all this ground
yeah i think i will ๐
it steps through all the challenges, and how to overcome them to the extent reasonably possible
There's even a github linked from it
How do you adjust for interpolation of character movement while using RPC for actions like shoot?
I've implemented Valve's character-interpolation on 20 network-ticks and previous 200ms of data
but my RPC-action are nowhere near in sync
I'm using PUN2 by the way
I'm starting to experiment with turn-based multiplayer on Android. I just wanted to ask before I got too deep: Is there a commonly accepted way to do this kinda thing? Or at least a good place to start, before I go barking up the wrong tree? I'm new to trying online multiplayer in Unity and I'm having trouble sorting through the old/contradictor/expensive advice.
I found this post that seemed like a good start:
https://medium.com/@div5yesh/turn-based-multiplayer-games-in-unity3d-using-unet-abcd8360ddd5
but then found out Unity recently announced they are deprecating UNet, so I'm not sure what to think.
So, any general pointing in the right direct would be wonderful.
While Mirror is a very good direct replacement for the deprecated UNet, such packages may well be overkill for a turn-based game if you don't need server-side physics, collisions, raycasting, or nav mesh agents. If that's the case, a simple server, or perhaps even a web service might suffice. Just sayin' think through your needs carefully.
Unity is still updating UNet too
they just released new package for HLAPI today
an HLAPI package is going to stay around throughout 2018 LTS, so for next 2 years
LLAPI is going to say for year longer with 2019 LTS
## [1.0.2] - 2019-03-18
### Changed
- Fixed issue with population of Syncvar variable on a class derived from a networkbehaviour base class (case 1066429)
- Fixed issue with IsDynamic not working on .net 3.5 profile (use something else)]
- Fixed file lock error when building under certain conditions (case 1115492)
## [1.0.1] - 2019-02-14
### Changed
- Disabled warnings around the usage of the 'new' keyword in the NetworkTransform, it's needed sometimes but can trigger when building (likely because of stripping) and the warning messed with CI/automation
## [1.0.0] - 2019-02-13
### Changed
- Only updating version to 1.0.0 to reflect the status of the package
## [0.2.6-preview] - 2019-02-13
### Changed
- Got rid of all warnings generated when the package is built, so it's CI/automation friendly
- Readme updated
## [0.2.5-preview] - 2019-01-29
### Changed
- Fixed Syncvar variable update issue. Modify both the writing and reading syncvar data as per channel. (Fixed cases 1110031, 1111442 and 1117258)
## [0.2.4-preview] - 2019-01-11
### Changed
- Fixed issue with assembly dependencies not being found by the weaver during certain conditions (like when doing full reimport).
### Added
- Added API documentation, migrated from unity source repo, only some formatting changes, text itself unchanged.
## [0.2.3-preview] - 2018-12-17
### This is the first release of the *Unity Multiplayer HLAPI \<com.unity.multiplayer-hlapi\>*.
Initial release of the Unity Multiplayer HLAPI (or UNet HLAPI) moved into a package. This will
work with Unity 2019.1.0a12 and onwards.```
(from HLAPI changelog)
what networking solution would you use for a 2d webgl game?
Mirror since it's one of the few that actually supports WS and WSS
That's assuming you need Unity features on the server. If you don't then Mirror is overkill.
MLAPI
or even hlapi from package manager
does it matter? if it's your first game use anything, photon even has a free option
myeah i am trying photon 2 right now but it gets compile errors when i switch build target to webgl ๐ค
@quaint marsh find the PhotonUnityNetworking asmdef and add the PhotonWebSocket reference to it
i dont have that
oh there it is. i guess i cant search for *.asmdef in the project
there we go! boom! everything is green! :D
glad to help ๐
I appreciate unity's investment into multiplay but I supect it would be slightly more useful with a robust networking library :P
hot take
You really expect more?
I hope so!
From the multiplay code they put on git so far I am crying hard
It's like they know nothing about how OS works with networking IO
But vince you would be unhappy if you didn't have something to moan about. Be thankful they give you beautiful moments of hate
๐ฆ
I spend 90% of my time making solutions and code or using assets for basic things an engine should have
I got annoyed over the last 6 years working in unity
forgive me
honestly I don't know what is happening with unity networking, just make sure you never use @ followed by these letters without spaces: f h o l m
after the LLAPI/HLAPI fiasco I don't trust unity
and then they came with this new multiplayer layer
and it's like the worst implementation for scalable network interfaces you can come up with
same, I coded an FPS tank battle game in HLAPI and realised it had really bad memory management
especially since they slap it into jobs without even knowing how IO scaling works on the Operating System, a big overhead layer that will not scale.
then I looked into LLAPI, then unity depreciated it all.. so I dropped it and now my trust is a little burned
I really enjoy what some unity teams are making, like what is happening on PostFX, Scriptable render pipelines and so on is amazing. but why can't they not invest the same into multiplayer
they are, is my understanding
it's just very early
and I agree with the skepticism, overall
LLAPI dies with more than 8 players ie reliable messages never arrive, so that's useless, HLAPI is just a broken mess by itself
They are not Jason
What they uploaded is the worst implementation on UDP i ever seen
and i've seen a lot
thing is it's not "early"
it's been quite some time between stopping work on unet (2+ years ago) til now... that's time enough, surely?
whats the new shit called again?
IT's like somebody that doesen't know anything about how Networking works, or Operating systems, decided to just take a wraper around native sockets, slap it in some jobs and say it's scalable (which it isent)
well it's fine for a 4-8 player game i think if allocations are pooled
The most important thing you would expect from an UDP network library to have Reliable channels perhaps, be low level and fast and be scalable
but i didn't know LLAPI was also flawed
meaning an rUDP impl?
yeah
got it
But great reliable UDP libraries exist
yeah
enet would be a good bet
why re-invent the wheel (badly) and then slap Jobs on it
photon is built on enet btw
and its tight
we use it too btw
you could opt for a more modern way to interact with OS
but at least that works yes
better than unity networking for sure
i don't use enet because i want a lot of things taken care of - i need matchmaking, i need host migration and I need relays done for me - i simply have no time.
all of those are only covered by photon atm :(
so I need an overall package solution
this does not exist really does it
no servers
i need the server infrastructure to be fully managed not by me
so i guess your options are Photon, SpartialOS
that's actually the main thing i need, because code is not a problem... having servers get hit or compromised or just slyly hacked for furture ddos purposes (quite common) can add up to a seriously expensive mistake on my part...
so having that properly managed with the provided having accountability is good
I don't know how anyone can talk about Spatial after the crap they pulled with Unity
i'd never touch them with a 10 foot pole now
lol @ spatial
any company reacting like they did instead of coming to the table to talk.... reacting by immediately running to the nearest competitor ... what a joke
i will never use them.
they lost badly though, they may be able to use all of unity's tech for free but their name is now mud fo the biggest game engine in the world
in their defense - I'm pretty sure this is at the end of a lot of failed talks
haha