#archived-networking

1 messages · Page 89 of 1

ember tulip
viral charm
#

Hello

#

I have a question regarding how to get into the server side part of game dev and MMO server Programming

#

I want to know how to get started I know C# did some basic servers and clients but this is actually my passion is the networking part of things my question is do I have to be good at game Programming in order to program the server ? Because I think most game Programming stuff will be in the client !

#
  • how to get and study the networking part / backend in MMO Programming
sweet turtle
grizzled narwhal
#

@sweet turtle Don't cross post your question

somber drum
# viral charm I want to know how to get started I know C# did some basic servers and clients b...

Do you have to be good at programming to build an mmo server? Yes, its actually the most difficult.

You say you know c# and have set up basic servers- but I'm guessing not a game server?
Your game programming will actually need to be sent to the server if you want any of it to synced to other players.. Which is more than hitting a switch.
So it's a lot of work, if you're not familiar.
If you are familiar- its still an mmo..

Handling massive amounts of players is not an easy task, no discord response could answer this properly in a way you'd learn properly so I would say research it.. Plenty on google

Where to get started? Write ups, books, Youtube, google, learning some simple structures by looking at some template assets would be my suggestions.

+dont make your first game, let alone first multiplayer game, an mmo.

safe lynx
#

ok i have an interesting networking problem. so i have an enemy script that targets a specific player using a nav agent. now im not 100% sure how i should go about networking it. should i have the person that the enemy is targeting do all of the position calculations and have all other users just update the position given by the targeted user or should i have each separate client calculate the enemy's nav mesh and just network the target
or the third option is have the host do all of the calculations
the first option would be fine except if the first user has bad internet and all the enemy's tracking him would lag with the user. the second option would cause sync problems where the enemy's are on different spots per client if there was any problems. and the third option relys on the host having good internet and i think is a generally bad idea

#

were still in the early stages of networking and i want to get a good framework down that we can use across the board

#

this isn't going to be a competitive game its going to be coop and were not going to worry about hacking or anything like that for the time being

#

this is probably one of those big problems you have to solve early on. like should we use a host client system strictly or a p2p type system

white stone
#

Personally i would choose P2P, so who ever is the host of the session is like the server. Really comes down to the type of game it is.

safe lynx
#

option A or B

#

Theres gonna be more than just 2 or 3 though

#

and we don't have a dedicated server to run this on were just using Photon

#

heres the three options i came up with

#

the arrows kinda show the information being shared. in this case it could be the positional data

earnest leaf
#

How can i cloud save for free(non google services)??

somber drum
#

these are paid services for a reason

#

I don't know of any way to make commercial cloud saves, for free

safe lynx
#

Yea lol I’m just using google firebase for basic data persistence and using photon for the actual networking. I’m planning on changing over from photon to a self hosted php server running on my computer

prime dawn
#

does that mean that I have to put it in update?

#

oke

prime dawn
#

WHAT?!

#

THEY ADDED DEDICATED SERVER?!!

#

That makes everything so much easier

#

OMG

safe lynx
#

!!!

#

Wait is that what I think that means?

#

Server side code?

#

@prime dawn

burnt temple
#

hello iam making my own multiplayer code
with my own framework
i want to add online multiplayer bc i have it now on lan
so
when someone hosts a game add a new record with the host's code+public ip then the other client can enter the code on their end. you lookup the code in the database and retrieve the ip address
^ is that allowed on google play?

safe lynx
#

I couldn’t see why not?

#

If you need to do it for it to work than you should be able to do it

burnt temple
#

iam scared bc google might suspend the acc

burnt temple
#

but iam just super scared

gleaming prawn
#

@safe lynx and @prime dawn photon always had the enterprise offerings to let you write server side code over dedicated servers (it’s a photon specific api, called photon server plug-ins)

#

This has nothing to do with hosting a unity instance as a server, for example.

#

This was not added, this has been there since a long long time.

prime dawn
#

now..

#

how can I add only the lastest mesage?

#

is the newest message going to have index of 0?

#

or should I check the length and use the last index?

vapid seal
#

u dont have to use photon

#

i just use system.net.sockets

#

its easy

#

and u send string or whatever u want

#

and u can make ur own dedicated server

alpine pivot
steady sedge
#

Hi, i have a problem with mirror.
I have to players (with the authority set to the client) and they both have a health script. There health variable is synced across all clients and the server. I also have a weapon script on the player which calls a function on the other player which takes some of its health away. This works fine for the player that connects to the host, but if i want to damage the other player as the host it doesnt work and i get this error message.

#

I dont get why this is working for one client but not for the host because its the same code running for both players

neon willow
#

hi, im trying to make a multiplayer demo with a dedicated server. ive set up two seperate unity projects, one for the server and one for the client. i can send messages between server and client, however, im not sure how to get the connectionId of the client. the client connects to the server through this function in the client.cs script that is attached to an empty gameobject in the scene:

void Connect()
    {
        NetworkClient _client = new NetworkClient();
        RegisterHandlers();
        _client.Connect("localhost", 7777);
        Debug.Log(_client.connection.connectionId);
    }

the last line causes an error saying NullReferenceException: Object reference not set to an instance of an object
does the first line not create _client as an instance? how can i get the connectionId of the client connected? im lost and any help/advice is greatly appreciated :d thank you!

grim violet
#

is connectionId something assigned once connected?

neon willow
#

it has to be smt in the form of like Instance.NetworkConnection.connectionId but im not sure if im creating client instance correctly or at all or idk

grim violet
#

so you have to wait its connected before trying to get that variable

#

when you do client.connect its not instant

#

it gotta go trought connection and allow it and return an id somehow, while your code continue to run meanwhile

#

just dont debug there

#

for that variable

neon willow
#

wait

#

i am

#

dumb

#

thank you so much LOL

lyric herald
#
    {
        if (PhotonNetwork.IsMasterClient)
        {
            float opponent = Random.Range(0, 100);

            if (PV.IsMine && opponent < 50)
            {
                CreateController();
                down = true;
            }

            if (PV.IsMine && opponent > 50)
            {
                CreateController1();
                down = false;
            }
        }
        else if (!PhotonNetwork.IsMasterClient)
        {
            if (PV.IsMine && down)
            {
                CreateController();
            }

            if (PV.IsMine && !down)
            {
                CreateController1();
            }
        }
    }```Hello, i have a question. Why does this system doesn't work. Sometimes the method CreateController() is called twice 😦
#

my guess is that the player who isn't the masterclient doesn't receives the bool down but how do i fix this?

worldly plinth
#

Hey, I'm trying to figure out best way to make my new multiplayer game.
I want players to be able to host the game themselves as well as make dedicated servers.
Dedicated server will be made in Unity anyways because I need to do some server side simulation.
So I'm thinking if it's possible to put that scene I make for dedicated server in the client as well and when someone hosts the game would it be possible to run 2 scenes at the same time?
Like does unity allow me to run one scene in the background while player is playing on another one?
Working with one scene that I could use in both cases would be best solution for me as solo game developer.

lyric herald
#

Hello I have another question! When I disconnect from Photon and after that I want to join a room again I get this error: MissingReferenceException: The object of type 'RoomManager' has been destroyed but you are still trying to access it.if (CountdownTimer <= 0) { if(RoomManager.Instance.gameObject != null) { Destroy(RoomManager.Instance.gameObject); } StartCoroutine("DisconnectAndLoad"); } That's where the error is.

tawdry pike
#

@worldly plinth if you would create a server process that will handle the game state, you could also start this process locally when you want to let the 'user' create a game right? It should not matter if a client runs the server or if you run this in a data center (as long as the other players get access to this server). The latency will just be better for the player hosting the server 🙂

#

@lyric herald is the RoomManager as singleton (I am not familiar with Proton)? Do you have access to the object in the Coroutine (new thread?)

lyric herald
lyric herald
tawdry pike
#

You could debug the code and see what 'this' is in RoomManager.Instance = this below the destroy.

lyric herald
#

@tawdry pike I don't know what to do 🙂

wooden folio
#

Hi, new here. I'm working on my first game, 2 player, 2d board game. Chose Unity mostly for platform coverage. I've got single board mode petty much done, so netcode is the next thing. After a bit of research, favoring PUN due to simplicity and humble requirements. Mirror would be my second choice. Question about PUN: Will PUN satisfy needs around user management? E.g. user account persistence, rating system, etc.

jade glacier
#

As you are probably reading, all photon products are about realtime synchronization of state and such. Photon doesn't deal with persistence at all, as those are much better served by cloud services. @wooden folio

earnest leaf
#

Is it hard to implement google services in game and save variables in to cloud?

severe owl
#

i have not tried in years but i was a complete noob and managed googles cloud save using some plugin they made at the time.

wooden folio
#

Installed PUN. I created my NetworkManager class, derived from MonoBehaviourPunCallbacks, but vscode can't see that class, or anything in the Proton.Pun namespace. My app runs, so it's not a typo in my code, and vscode finds other unity content (such as MonoBehaviour from Photon.Pun).

wooden folio
#

Update: problem solved. Using Visual Studio 2019 instead of vscode.

slow monolith
#

How many FPS should my unity based server run at

#

is 30fps enough? I have to do physics simulations btw

gleaming prawn
#

Depends on the game you are building

slow monolith
#

first person shooter

gleaming prawn
#

60 then

#

If it’s a competitive shooter

jade glacier
#

VS Code has issues with Unity, that comes up often @wooden folio

wooden folio
#

@jade glacier now it's happening with Visual Studio too! But here's a clue: if I delete the sln file, the problem goes away (a new sln is generated when I open source code from Unity). So now it looks like Unity is corrupting the sln (or presumably the vscode project in the case of vscode).

#

I imagine the problem will come back, so I'll keep deleting the sln, and try to pay attention to possible triggers.

craggy maple
#

how come i cant access DownloadHandlerTexture or UnityWebRequestTexture from unityengine.networking in 2020.1?

#

did they remove it or something>

#

do i need to download HLAPI?

jade glacier
#

it is still there
UnityEngine.Networking.UnityWebRequestTexture

#

But Networking suggests SUPER old legacy

#

Or was Networking Unet, I don't even recall any more what the namespaces were. But yeah. That is tied to obsolete networking libraries.

slow monolith
#

When the client sends his packets, do I need to include information about EVERY frame between the updates?

#

That would seem like quite a lot of information

weary lark
#

I keep getting this warning while using mirror and my games not working does anyone know what this means?

#

Component [-1] not found for [netId=2]
UnityEngine.Logger:Log(LogType, Object)
Mirror.ILoggerExtensions:LogWarning(ILogger, Object) (at Assets/Mirror/Runtime/Logging/LogFactory.cs:93)
Mirror.NetworkIdentity:HandleRemoteCall(Int32, Int32, MirrorInvokeType, NetworkReader, NetworkConnectionToClient) (at Assets/Mirror/Runtime/NetworkIdentity.cs:1087)
Mirror.NetworkServer:OnCommandMessage(NetworkConnection, CommandMessage) (at Assets/Mirror/Runtime/NetworkServer.cs:1007)
Mirror.<>c__DisplayClass6_02:<WrapHandler>b__0(NetworkConnection, NetworkReader, Int32) (at Assets/Mirror/Runtime/MessagePacker.cs:120) Mirror.NetworkConnection:TransportReceive(ArraySegment1, Int32) (at Assets/Mirror/Runtime/NetworkConnection.cs:251)
Mirror.NetworkServer:OnDataReceived(Int32, ArraySegment1, Int32) (at Assets/Mirror/Runtime/NetworkServer.cs:570) kcp2k.KcpTransport:<Awake>b__12_5(Int32, ArraySegment1) (at Assets/Mirror/Runtime/Transport/KCP/MirrorTransport/KcpTransport.cs:61)
kcp2k.<>c__DisplayClass21_0:<Tick>b__1(ArraySegment`1) (at Assets/Mirror/Runtime/Transport/KCP/kcp2k/highlevel/KcpServer.cs:185)
kcp2k.KcpConnection:TickAuthenticated(UInt32) (at Assets/Mirror/Runtime/Transport/KCP/kcp2k/highlevel/KcpConnection.cs:265)
kcp2k.KcpConnection:Tick() (at Assets/Mirror/Runtime/Transport/KCP/kcp2k/highlevel/KcpConnection.cs:285)
kcp2k.KcpServer:Tick() (at Assets/Mirror/Runtime/Transport/KCP/kcp2k/highlevel/KcpServer.cs:240)
kcp2k.KcpTransport:LateUpdate() (at Assets/Mirror/Runtime/Transport/KCP/MirrorTransport/KcpTransport.cs:111)

cold viper
#

Hey guys I'm trying to use WebClient/HttpClient asyncly and sometimes I get over a minute response time, for what it normally takes .2 sec. I set the proxy to null, but it still takes sometimes to a minute for the progresschanged event to even fire. Is the thread maybe blocked or something, has anybody had this problem, or is there any reliable solution, because it's getting really frustrating.

somber drum
#

I'm curious what you all think of this, if this is something that could be helpful or if I should just learn it all myself.. what are the benefits and how big of a wheel am I reinventing here?

jade glacier
#

If it is just compressing the byte[] before it is sent, probably not the best way to go about dealing with network compression.

#

Typically you want to make use of delta compression and bitpacking if you are trying to manhandle data rates.

#

This does seem to delta between writes, so that depends on you doing NO custom serialization and just serializing all of your data uncompressed into your byte[], and then running this on it each send.

jade glacier
#

With unreliable connections, it will also need to keep a history to delta against. Because if the last delta didn't get through it needs to know, or it will be producing garbage.

somber drum
#

thank you so much, I'll take this with a grain of salt then and do some research

jade glacier
#

It is free, so you can certainly download it and play with the API. You might be able to make use of parts of it.

#

Actually, it looks like a bitpacking library. Which is good. There are many of them. I have one I made public as well.

dusky wedge
#

does anyone know any videos where i can learn how to make multiplayer (I know nothing about multiplayer btw)

somber drum
weak plinth
#

Is there a way I can use Unity to hole punch both TCP & UDP as well as turn my device ITSELF ( laptop, computer, android phone, etc ) into a DNS server? kinda' like a mobile server

alpine pivot
lofty hemlock
#

Do all popular solutions (Mirror, Photon, SmartFoxServer, Forge) work with Switch Console? If not, which are compatible? (Googling is tough because "switch" is just too common a word.)

#

(Ideally for cross-platform play)

reef gust
#

what type of network solution would one prefer if they didn't necessarily want a "multiplayer game," but an idle game where logic is controlled by the server to prevent cheating

#

would also need to store information in a database, such as gold, but that wouldn't need to be related to the server. The server would need to communicate with the database to update it though. ie if the player spends gold to roll a random item, the roll would be done on the server, which would update the database

digital urchin
# reef gust would also need to store information in a database, such as gold, but that would...

You are more than likely wanting to simulate it on the server and stream it to the client. Granted it is an idle game, and most don't really care that much. Honestly, wouldn't try and make it so you couldn't cheat unless there are actual in game stacks to someone else cheating. If it ruins just that one persons experience, honestly it is fine. Just make sure that you do a few checks on the server and it should be all good.

reef gust
#

can you elaborate on "simulate it on the server and stream it to the client"?

#

& wanting to make it server based so legit people can compare scores. Would rather have the server control the few logic that there will be rather than search and remove illegitimate data

slow monolith
#

So I've gotten around to building my multiplayer from scratch

So should I
A.) Process and apply player movement packets AS SOON as they're received by the server
OR
B.) Store information and only apply movements and stuff in intervals, say every 10 milliseconds

slow monolith
#

This is all for the server btw

open flume
#

This has probably been asked a milion times but. Im fairly new and want to make a multiplayer game without any multiplayer experience. But i cant seem to find any tutorial that is easy to follow and not outdated. if anyone has recomendations to tutorials or networking solutions please let me know. Also Happy 2021

spring crane
#

PUN2 is one of the easiest high level networking solutions. Mirror(very similar to UNet) would be a second one with a strong community. The major difference between the two is that PUN2 is peer to peer over relay, while Mirror is the more classic client - server setup.
Worth mentioning that MLAPI is now part of Unity, but there are some revamps in the horizon and the userbase has been a lot smaller from what I've seen.

#

You should be very comfortable with the basics of C# and Unity game development before throwing networking into the mix.

weak plinth
#

hmmmmmmmmmm

#

guys

#

can someone help me?

spring crane
#

Not really if you don't ask the actual question

weak plinth
#

oh

#

wait

#

i need pun

#

why there is no pun?

#

i think i have imported everything

spring crane
#

Not sure. I would probably try restoring it to a state of no compiler errors, closing your IDE and Unity Editor, deleting .sln and .csproj files from the project and starting Unity again.

weak plinth
#

🤔

#

so

#

should i delete all the scripts i made?

weak plinth
#

REEEEEEEEE

#

wtf

#

whats wrong?

weak plinth
#

So...?

mild reef
#

You recompiled your code while playing it looks like. That always breaks stuff.

graceful zephyr
#

Stream at 9PM (CET) tonight, 5 and 1/2 hours from now, at http://twitch.tv/fholm - will finish up the udp transport and then talk about snapshot interpolation, etc.

Twitch

fholm streams live on Twitch! Check out their videos, sign up to chat, and join their community.

▶ Play video
finite igloo
#

Hello guys, could someone provide me some basics or example of picking up some items? I have a script, but the script requires character, camera.. etc but i cannot pre-select anything ( due to multiple players ) but when it's empty, it is causing errors. Could please someone provide me some basics of how to do this ? Thanks.

lean field
#

Do you think that it is a good and possible way to create a game server

#

?

slim ridge
#

pretty good

#

you can put anti-cheat on the same node as the server who propagates it

#

or built it into each node after the proxy

#

depending on what it actually does 🤷

vague solar
#

Hello everyone I'm new to Unity and programming.
I have tried following a tutorial on youtube about making a multiplayer game. I have arrived at a certain problem though.
When creating a "Plane" on the server side at 0,0,0 coords it's invisible so I created another "Plane" on the Client side at 0,0,0 however they don't match. Somehow the Plane on the client side needs to be adjusted by 10 on the Z axis in order to match and something like -1 on the Y Axis.
Any help would be appreciated 🙂

jade glacier
#

You should probably mention which networking Library. And whichever library you are using, you should start with the tutorial that that library recommends. @vague solar

vague solar
#

I have found the issue and fixed it. It was SO simple this is so frustrating.
Regardless thanks for the help 🙂

jade glacier
#

So what was it?

#

If you posted that on the forum, can you kill that post too if it wasn't a Photon issue? @vague solar

vague solar
# jade glacier So what was it?

I did not make a post about it. The issue wasn't Photon but my own puny brain. I have maid an EmptyObject and called it World which I had all my GameObjects inside (Plane, Cubes, etc...) and I set that world for some reason (only god knows why) to be at Y axis -1 and Z axis 10 instead of just leaving it on 0 0 0

jade glacier
#

oops, sorry, was confusing this with another conversation I was having in a different channel about Unity crashing. Nm.

vague solar
#

NP just had 3 hours taken from my life lol
Leave and learn I guess

last yoke
lean field
charred swan
#

and the code that I wrote for parsing ans showing that is like 👇

socket.On("lap", (E) =>
{
    Debug.Log(E.data[0]["x"]);
}

but nothing comes back

#

what's the problem of my code?

weak plinth
#

i'm interested in firebase too. just discovered it late last night. i'd love some developer opinions on it

weak plinth
#

That was one of my concerns, how much the cost would be

#

I’m not sure yet what solution I’m looking for. So far the ones I’ve found (mirror, photon, etc) don’t look like they’re what I’m looking for.

#

I need online data storage in my game but not “matching” or “see all the players on the screen”

#

Ok gpg as in the encryption ?

#

I’m thinking you mean google play games and not the encryption. Tech and their recycled acronyms 🤯

weak plinth
#

is 'gamesparks' and 'pgp' technically a networking thing or is there a better channel to discuss these things?

oak flower
#

Anything network related fits in here.

weak plinth
#

ok thanks @oak flower

#

Has anyone got an opinion or experience about GameSparks?

severe owl
#

If your storing user data in the cloud make sure to check the marketplace ecosystem your in.
Like Steam has some cloud save functions built in.

slim ridge
#

if you go with gamespark make sure you need all those features yea

shadow pebble
#

Hi all, I have some really stupid beginner questions about networking but dont want to spam the chat and irritate everyone. Is anyone free that I could ask a couple of questions to?

jade glacier
#

Best to just post the questions. People will just ignore it if they don't have an answer for you. @shadow pebble

shadow pebble
#

Thanks mate, so main question is when im using mirror and running locally I have methods that are run by the client and methods run by the server. Im looking at hosting a server build on playfab for the generous free tier but in what way does my server build need to differ from the build my clients run?

jade glacier
#

I would join the Mirror discord and ask that, they will have better Mirror specific answers.

shadow pebble
#

ok cool, thanks

slim ridge
#

just check "server build" in build options

ember tulip
#

Hey all, could use some general tips here. I'll keep it general.

I'm doing mostly client authoritative. I have an ability that a player can use. I have it implemented as a state machine, as the player goes through a windup, aiming, shooting, and completing. There's timings associated with these, like needing to wait for windup to finish, etc.

For networking this, I originally had each client (even remotes) going through all the states. They'd run all the behavior. The local player would have the input that drives things.

I'm thinking this is probably error prone though. Like if a player's input doesn't come in with the right time, then a remote could be trying to process their second action while the remote instance isn't ready, perhaps still in the windup state.

So I think what it comes down to is handling state machines with networking. I'm thinking perhaps the local player should have the state machine, and the remote players don't run any of the logic. They just transition to the next state when RPC'd, no questions asked, and trigger animations.

Am I on the right track there? Thanks for any help.

jade glacier
#

Be sure to indicate which library you are using when asking questions in this channel - since it isn't specific to any one lib. @ember tulip

ember tulip
#

Sure, this is for Photon PUN in my case, though I'm trying to think about it generically

#

To be specific about my current issue:

The player has a bow. Hold left click to aim, let go to shoot.
It goes through a short windup, and then is ready to shoot.
If the player lets go of left click during the windup, the 'shoot' action will be queued, so the shoot happens as soon as the windup is done.

Right now, the RPC's being sent are to start the windup, and to do the shoot. Then each remote does this same logic that the local does. So each remote won't allow the shoot until the windup is done.

It seems to work, but I just feel like it is maybe fragile. For example, queuing the shoot could be on just the local, and then once the shoot actually happens, it RPC's and all remotes just start the shooting, regardless of their own windup.

Perhaps I'm overthinking it. I don't know.

#

I kinda feel like writing all of the above helped me work through it and I have a path. I think I'll rework this a bit and have the local player contain the majority of the logic. Remotes will replicate that logic when it comes to animations and such, but won't enforce state transition requirements.

oblique fog
#

I went with PUN on a previous project because of its free 20 CCU tier, which was similar to UNET matchmaking tier. It worked great to test run it without having to fork up money. However Photon doesn’t have a built in LAN solution, so I’m forced to look at Mirror...which doesn’t come with a plan like PUN (understandable). Does anyone know of a good combination for Unity/Mirror and some compatible online matchmaking service that has a free tier to sandbox before committing?

I did some general research and found Azure’s PlayFab solution. Is that a good fit for what I’m looking, or are there better combinations?

somber drum
#

GameSparks/Playfab were the goto a while back, one of them changed their indie tier and people grumbled, not sure though

#

Photon not having LAN is something I'd not heard of, I guess it makes sense out of the box being it goes through their cloud

slim ridge
#

synchronizing things like this across clients requires some form of tick-based update system. You can't trust the time on client machines or even how it's counted. check this out:
https://github.com/emotitron/SNS_PUN2/

jade glacier
#

That is out of Beta @slim ridge Simple is part of Pun2

#

The current Pun2 on the asset store has it built in.

slow monolith
#
    {

        Physics.autoSimulation = false;

        for (int i = 0; i < totalArray.NetworkingPlayerRotationX.Count; i++)
        {

            Player.transform.localRotation = Quaternion.Euler(0, totalArray.NetworkingPlayerRotationX[i], 0);
            PlayerRigidBody.velocity = totalArray.NetworkingPlayerVelocity[i] * 5f;
            Physics.Simulate(0.02f);
            PlayerRigidBody.velocity = new Vector3(0, 0, 0);

        }

        Physics.autoSimulation = true;

    }```
#

Here's my serverside code for updating player positions

#

note how I turn off autosimulation, then re-enable it, for precise movments

#

will this cause problems?

#

Yeah that definitely causes problems. Should I be doing serverside physics on the fixed timestep clock?

#

instead of trying to force it in one frame with physics simulate?

slow monolith
#

Should I just queue up velocity events and only execute one per gameobject per fixed timestep?

slow monolith
#

Okay so I implemented that ^, and it seems to work great, but the server is behind like a whole second on a local connection

#

is that normal?

ionic crag
#

Any networking for unity5x?

gleaming prawn
#

I think PUN classic still officially supports Unity5, but I might be wrong.

tight basin
#

I'm trying to make my Unity application able to send web requests to an external API of mine (which works with HttpWebRequests). This isn't a problem, but I'm also trying to send signals the other way (API->Unity), because I want people to be able to choose when to start a training from our online website.
An alternative would be to do requests ever x seconds to see if the API has had variables changed, but that's far from the most efficient solution.

slim ridge
#

if you want a two-way connection you can use a simple TCP protocol.
otherwise polling is a practical and efficient solution

sly fable
#

imported photon to my project but im having namespace errors I checked all the files trying to be imported and I cant even find the script its trying to reference

jade glacier
#

Are you using VS Code?

#

@sly fable

slow monolith
#

Here is a client script, and for some reason, it can send messages properly, but cannot receive them

        u.Client.ConnectAsync("127.0.0.1", 9050);
        Byte[] sendBytes = Encoding.ASCII.GetBytes("Is anybody there?");
        u.SendAsync(sendBytes, sendBytes.Length);
        StartNetworking();

    }

    public async Task StartNetworking()
    {

        var receivedResults = await u.ReceiveAsync();
        Debug.Log(receivedResults.ToString());
        StartNetworking();

    }```
#
        StartNetworking();

    }

    public async Task StartNetworking()
    {

        var receivedResults = await u.ReceiveAsync();
        Byte[] sendBytes = Encoding.ASCII.GetBytes("Send 2 Client");
        u.SendAsync(sendBytes, sendBytes.Length, receivedResults.RemoteEndPoint);        
        StartNetworking();

    }

Here is the server script, it can receive messages just fine. Any clue as to why the client isn't working properly?

safe lynx
#

hey im trying to setup xxamp for my untity game but my router has a weird properity that its unable to port forward to itself. so im unable to load the database from my IP address but i think other people can

#

i just need someone to open up this link and send me a screenshot of what pops up :P

#

i know this sounds shady af but i cant think of another way of doing this lmao

#

i dont want to post my IP address in public so please DM for the link

#

nvm

idle sonnet
#

i can net work yay

sly fable
#

@jade glacier i fixed it

#

the missing script was in a demo/example folder I didnt import for some reason...

#

anyways does photon work well with webgl?

weak plinth
#

how can i fix it?

#

anyone

oak flower
weak plinth
gleaming prawn
#

This class inherits from mono behaviour, so should be fine

weak plinth
#

but isnt

#

idk why

#

also

#

i made it waching a tutorial

gleaming prawn
#

Is there another@compilation error?

weak plinth
#

and i think i made everything fine

weak plinth
#

so...?

#

@oak flower

#

@gleaming prawn

oak flower
weak plinth
#

what do You mean?

gleaming prawn
#

Sorry, off with family now

weak plinth
#

Ok

white stone
#

@weak plinth Share the tutorial you followed and received the error so others can see if the error reproduces.

weak plinth
#

This is the second lesson in this Unity multiplayer tutorial series. In this lesson, we will teach you how to make a quick start matchmaking system. This will allow the player to click one single button which will then load them into a multiplayer match.

Discord: https://discord.gg/hGJ4CRE
Website: https://infogamerhub.com
Become a Member: htt...

▶ Play video
#
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;

public class QuickStartLobbyComponent : MonoBehaviourPunCallbacks
{
    [SerializeField]
    private GameObject quickStartButton;
    [SerializeField]
    private GameObject quickCancelButton;
    [SerializeField]
    private int RoomSize;

    public override void OnConnectedToMaster()
    {
        PhotonNetwork.AutomaticallySyncScene = true;
        quickStartButton.SetActive(true);
    }

    public void QuickStart()
    {
        quickStartButton.SetActive(false);
        quickStartButton.SetActive(true);
        PhotonNetwork.JoinRandomRoom();
        Debug.Log("Quick start!");
    }

    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        Debug.Log("Falied to join a room!");
        CreateRoom();
    }

    void CreateRoom()
    {
        Debug.Log("Creating a room...");
        int randomRoomNumber = Random.Range(0, 10000);
        RoomOptions roomOps = new RoomOptions { IsOpen = true, IsVisible = true, MaxPlayers = (byte)RoomSize };
        PhotonNetwork.CreateRoom("Room#" + randomRoomNumber, roomOps);
        Debug.Log("The room was created: Room#" + randomRoomNumber);
    }

    public override void OnCreateRoomFailed(short returnCode, string message)
    {
        Debug.Log("Falied to create a room... Try again.");
        CreateRoom();
    }

    // Update is called once per frame
    public void QuickCancel()
    {
        quickCancelButton.SetActive(false);
        quickStartButton.SetActive(true);
        PhotonNetwork.LeaveRoom();
    }
}
#

the code

#

uh

#

repaired

#

just called the script wrong

#

reeeeeeeeeeee

#

anyway

#

thx for help

#

everyone

zealous sundial
#

Someone know a tutorial for univoice ? Or knows any way to have p2p local voice chat ?

outer hinge
#

Hi all, does anyone here know if Mirror has an equivalent of Photon's "PhotonView.Owner" functionality? I'm trying to get usernames that players enter on the start screen to be visible above their heads to all players in the game. Having some trouble. Found a tutorial on YouTube that uses Photon to do it rather simply, but I'd rather not rebuild everything in Photon after all the work I've done with Mirror. This may be very simple, but I'm new to coding and having trouble sorting through Mirror's API so I'm pretty much stuck haha

spring crane
#

@outer hinge networkIdentity.connectionToServer maybe?

#

On the client I'm not sure if you can get the connectionID of other identities. Things generally in Mirror operate with the assumption that the state comes from the server.

loud geyser
#

Howdy, what is the current "proper" way to do Unity networking?

#

What library etc.

white stone
#

@loud geyser Read the pinned docs for starters

spring crane
#

@outer hinge Make sure to check out the official Mirror discord

white stone
#

No one will say use this and do this and thats the answer, way to many variables come into play

loud geyser
#

so are we recommending DOTS now? Last time I checked it was still too early

spring crane
#

Not afaik 😄

#

You do have some potentially interesting stuff out of the box with deterministic physics and some other stuff, but the "too early" stamp likely still applies

outer hinge
spring crane
#

MLAPI was recently acquired to replace UNet, but my understanding is that there will be major changes to MLAPI. Thirdparty Exitgames, Mirror, Forge and the like are likely still the more stable high level networking options for now.

loud geyser
#

nice, that's good to know! I will check out those libraries! Thanks a ton!

floral turtle
#

so it's not a ready to go system like Photon Quantum

spring crane
#

Oh thanks for the info. Apparently Burst is breaking that determinism based on a few forum posts.

weak plinth
#

@outer hinge if you werent able to fix dm me and I gotcha bud

dense hedge
#

Rather than breaking cross-platform determinism I would say more like Burst hasn't figured it out yet. Consistent floating-point math across different CPUs and compilers has never been a casually toggle-able option like Burst aims to have.

#

Photon Quantum uses fixed-point integer math to be globally deterministic.

versed yew
#

so if im making a game that isnt cross platform i can just use the normal unity physics and itll still be deterministic, right?

floral turtle
versed yew
#

oof

floral turtle
#

do you need determinism? It can be a huge investment to make a game deterministic, even beyond physics

versed yew
#

yeah

floral turtle
#

what genre is it?

versed yew
#

fighting

#

ive got the basics of velocity and movement and stuff
but collisions idk

floral turtle
#

if it's a pretty standard fighting game, you probably don't need a full physics engine

versed yew
#

i just need to figure out collisions and then ill be pretty much done with it

dense hedge
#

IIRC DOTS Physics actually is deterministic between Intel and AMD

floral turtle
#

DOTS is likely determ between them, since what breaks PhysX is probably SIMD. But you'd still need a deterministic game framework to manage object lifecycle/detect desyncs etc

floral turtle
#

(I haven't vetted that asset)

versed yew
#

this looks super useful, thanks

#

ok it's a bit too expensive for me right now

gleaming prawn
#

That asset was not deterministic when I last had contact with them. Maybe they fully redeveloped it

#

For fighting game’s determinism is pretty much the standard

#

But using a physics engomemos not, you normally just need basic collision detection, that you can copy and paste from any open source engine

versed yew
#

I've decided to just use the unity one but keep track of the collisions in my own time management thing and have stuff happen based on that

gleaming prawn
#

Unity’s is not deterministic, you will get desyncs

#

I mean I assume you want to do it o line, with something like ggpo

#

If it’s for a local game, no problem

versed yew
#

I think collision itself not being deterministic won't matter if all the movement is deterministic

floral turtle
versed yew
#

oh

weak plinth
#

The photon free version says max 20 CCU... does that mean maximum 20 players per room or only 20 players allowed to be playing at the same time?

versed yew
#

just tested
20 max at a time

#

so both I guess

weak plinth
#

oh rip... i was thinking of making a small battle royale game with like 50 players per room

#

is mirror able to achieve something like that?

grim violet
#

its like 100$ for 5 year for 100 ccu with photon, not that much really

urban stone
#

how do i fix this error User creation failled. Error 3
UnityEngine.Debug:Log(Object)
<Register>d__4:MoveNext() (at Assets/scripts/backendscripts/Registration.cs:35)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
code (for unity)
https://hatebin.com/hkiggzkglz
Code for php()
https://hatebin.com/neqvnpmpgj

vale mountain
#

is unity ever going to come out with unity networking

floral turtle
green reef
#

A simple Network issue, I think:
I have these two functions, CmdForward and RpcForward, you can view them here(like 6 lines of code):
https://pastebin.com/qJCVmJ6A
(channel = 3) is set to Unreliable Sequenced

When I press W forward is set to 1 on the clients almost instantly, but when I release W which uses the exact same function to set forward to 0, there is a long delay before 0 is set. If I hold forward for around 2 or more seconds before releasing, then the release message is received instantly like the initial send.

green reef
#

The delay is causing a big de-sync and is really hurting the game, I have correction in place that lerps, but the desync is so big that it causes a ton of sliding around anytime a direction is changed.

marble viper
#

so what would be a good asset to use for multiplayer games where one person hosts the game and you enter a game code to join their server (max 4 players per server) but I want an easy to use asset.

white stone
#

@marble viper Read the pinned docs for starters, read this entire thread, way to hard to pinpoint exactly one asset.

marble viper
#

ok

white stone
#

I often see people asking the same question and people are reluctant to come out and just say we use blah, it does this and this, costs this much, etc etc. People on here hold the networking close to themselves but will still provide guidance.

marble viper
#

I'm new to making multiplayer games, lol

#

I have like no clue

white stone
#

Most if not all on that first page are mentioned in this thread within the last 6+ months

#

@marble viper Check out the reviews on the assets, see what others are saying to get a general idea, sometimes you may end up buying a handful of different assets to work it out. The last week or so people were discussing Mirror and PUN in this thread

marble viper
#

I was looking at photon, but it says it comes with 20 ccu for free, but 20 ccu is like nothing

#

I want their to be game rooms filled with 4 players each with an infinite amount of rooms

white stone
#

read above, someone mentioned 100 for $100 5 years

marble viper
#

Do you know how among us does their server rooms?

white stone
#

Nope

#

But games in unity through steam, I often check there directories to see what assets they use to get a general idea on what direction they went etc

marble viper
#

I was just looking for a way to have infinite server rooms

#

ok

white stone
silent zinc
#

Guys can anybody help me improving my udp networking class and protocol for my 2D game?

#

i'm not completly satisfied with the results... i don't know if it is a protocol error or a game implementation error, but my character doesn't update smoothly ( like in 60 fps )

#

If anybody could have the time to help me, it would be amazing!

white stone
#

Ive no idea, have you tried the unity forum as well

silent zinc
#

for the client

#

server is a python server

#

basically, in the game manager, i call the Client.RecvPacket() in a separate thread, the client should receive the status of the other clients ( containing the x, y position of the character ). The processing of the packet is done in another thread. Every client, send their status in another thread, if the previous status is different from the current one

#

But the opponent updates really slow, how should i treat every packet?

#

For now my packet as this structure: bytePacketID + BodyLength + Body

rancid anvil
#

Hey , I'm actually new to aws , I started my instance , uploaded the server game side ,and launched it, but when I try to connect trought public ip , it tell me te following error : "Client Recv: failed to connect to ip=ec2-54-152-99-218.compute-1.amazonaws.com port=7777 reason=System.Net.Sockets.SocketException (0x80004005)"
What could I do wrong?
If someone would be able to help me , I'd be really glad

warm seal
#

how can i add networkManager to unity?

#

mám si to nějak stáhnout

#

I tried to download Multiplayer HLAPI but it is obsolete.

warm seal
#

i have 2020.1.17

slow monolith
#

Can someone explain how to do client side reconciliation inside unity?

#

I'm just using raw UDP and TCP sockets

#

I'm using rigidbodies btw

slow monolith
#

Or would I have to use the character controller

slow monolith
#

if I'm using physics, am I going to need to use physics.simulate?

weak plinth
#

im sorry if this is a stupid question but i cant find the solution anywhere even tho the error seems standard enough, im using parrelsync and mirror to make a game, and whenever I the 2 players collide or something I get a "CmdServerToClientSync called without an active client" error msg

graceful zephyr
#

Stream at 9PM (CET) tonight, 8 hours from now, at http://twitch.tv/fholm - will work more on snapshot interpolation and explain the more advanced parts about lowering buffer delay, etc.

graceful zephyr
austere bronze
#

I have a question, randomly while I was using localhost to connect to my own computer it stopped working dose anyone know why?

slow monolith
#

@gleaming prawn Have you ever made your own clientside reconciliation for rigidbodies in unity?

#

I'm looking for someone to point me in the right direction

gleaming prawn
#

Are you following fholms stream

#

?

#

He’s building something from scratch and will cover most of these topics

slow monolith
#

No I am not

gleaming prawn
#

Server reconciliation assumes you track time or ticks on both server and client

#

And on client you store an input buffer.

slow monolith
#

Yep thats all do-able

gleaming prawn
#

When client receives server data, snaps it and resimulate forward with the input buffer

slow monolith
#

Re-simulate with physics.simulate?

gleaming prawn
#

You do not interpolate simulation. You interpolate visuals

slow monolith
#

What about all of the other rigidbodies moving in the scene?

gleaming prawn
#

Unity physX is not good@for that

#

Other bodies you should normally make kinematic and do jot@predict

#

Just interpolate from server data

#

Your own object best is a character controller

#

Doing this with unity@rigidbody is not an issue with the reconciliation, but rather with the limitations of the physics engine

slow monolith
#

so it would be way easier to use a character controller instead of rigidbody

#

for the character

gleaming prawn
#

If you use a stateless@physics, it’s easier

#

Yes, that’s is one of the goals@of a kcc

slow monolith
#

So with the character controller, I can re-simulate multiple movements per frame right

#

and catch up pretty easily?

#

the default character controller component, included in unity

#

I'm a huge unity noob

gleaming prawn
#

Yes, you can. But the unity@one is quite heavy, be advised

slow monolith
#

hmm alright

gleaming prawn
#

There’s one called KcC that people say it’s better

slow monolith
#

I was really set on making this with a dynamic rigidbody :/ that sucks

#

During reconciliation, couldn't I just call physics.simulate every "catch up" movement on the rigidbody

#

and do that a bunch per frame

#

and sleep the other rigidbodies

#

which dont need to be moved

gleaming prawn
#

It’s too expensive to reset many tigidbodies in physx

#

Try it

slow monolith
#

ok

gleaming prawn
#

And remember, you need a tick system before any of that

#

Or at least proper timestamps

slow monolith
#

alright

gleaming prawn
#

You don’t add reconciliation, you build a system that has that built in

slow monolith
#

What's the point of a kinematic rigidbody though? Isn't that just the same thing as transforming a regular object?

gleaming prawn
#

No

#

A kcc works with a physics query normally

#

It is not inserted in the broadphase data as regular body

#

Depends on the engine. The kcc I wrote for quantum is just a query, so you can call as many times as you need, reset, etc

#

Although technically anything in quantum is reset all the time

slow monolith
#

Still very confused. Could you give a quick example?

gleaming prawn
#

But the kcc itself@would also be fine without determinism

#

Sorry, typing from phone

#

Putting kid to sleep

slow monolith
#

alright

#

Also I'm going to have cars in my scene, for which I will need dynamic rigidbodies with reconciliation

#

right?

gleaming prawn
#

Normally yes

#

Cars is a complicated topic

#

The easiest way to do car racing that I know of is the quantum approach

#

But what you can do is to extrapolate the other cars manually as kinematics

slow monolith
#

So you're telling me I'm going to need something like photon in the end?

gleaming prawn
#

You get the server data including player input and velocities

#

Compute a prediction based on that. Interpolate the visuals just slightly

#

No no... you can do like I just said without quantum

slow monolith
#

alright

gleaming prawn
#

But you are on your own to do it

#

With quantum it’s just a lot easier

slow monolith
#

Can all of this prediction computing be on the same scene

#

as the actual game

#

And I'm guessing you're just talking about running physics.simulate a bunch of times in a single frame?

gleaming prawn
#

Just for yours

#

I’m sorry, but you need to have the basics understood first

#

If you have a tick based system, input and data from server with all that, you can just extrapolate a kinematic

#

No need to step the physics engine for all cars

#

Only for yours

slow monolith
#

alright

#

Yeah I think im just gonna use photon haha

#

sounds like the best solution imo

#

Do AAA games use photon?

#

Like rust and tarkov and such?

gleaming prawn
#

Photon has several products

#

For what you are trying to do best is quantum which is not for free

#

Or the new fusion which will be released in a few months

slow monolith
#

ok

#

By stepping the physics engine for the car, you mean the car that the client is currently sitting in and controlling

#

only step his car?

#

and just extrapolate the others that hes not driving

gleaming prawn
#

Yes, exactly

slow monolith
#

alright

#

But If I'm snapping the car back and then running physics.simulate multiple times per frame

#

won't the client see all of that happening?

#

or is it too fast?

#

My other solution would be to have a ghost rigidbody following it, and the ghost rigidbody does all of the physics simulations

#

and then hands the final position value to the actual rigidbody

gleaming prawn
#

You step multiple times in one single update

#

Player only sees the final result

#

You also need to interpolate the visuals

slow monolith
#

And then I would just sleep the other cars that were moving

gleaming prawn
#

I really suggest you watch fholm streams

slow monolith
#

until the simulation is done?

gleaming prawn
#

There are several topics you are mixing which are required to work together

slow monolith
#

alright ill have a look. thanks

slow monolith
#

I watched a couple tutorials and I understand the ticks and stuff, the only thing im stuck on is actually re-simulating movements on the clientside

#

if I sleep all of the other rigidbodies and then loop a bunch of physics simulations inside a single frame, with the goal to only move a single rigidbody, the rigidbodies that I sleeped are going to appear to be stopped for a split second, if they were already in motion, right?

#

since fixedupdate runs differently?

#

Or should I loop the physics.simulate events inside fixedupdate instead?

#

The only thing that seems logical would to do the calculations in another scene, with only the player rigidbody in it

slow monolith
#

You don't know how much I would give to be able to simulate individual physics objects at a time

#

that would literally solve this problem

slow monolith
#

I'm a bit of a moron, so you'll have to explain this as if you were talking to a 10 year old

floral turtle
#

@slow monolith haven't followed the entire thing, but are you only trying to resimulate the character? You can do this if you make a custom character controller, or use something like this: https://assetstore.unity.com/packages/tools/physics/kinematic-character-controller-99131

Get the Kinematic Character Controller package from Philippe St-Amand and speed up your game development process. Find this & other Physics options on the Unity Asset Store.

#

also—is server authority necessary? Can be easier to just give clients authority of their char if you aren't worried about cheating

slow monolith
#

Server auth is necessary, and I'll need to use dynamic rigidbodies because of the cars

#

someone suggested full rollback

floral turtle
#

ahh it's cars, sorry I missed that

#

yea, I don't know any way to resimulate a single physics object beyond pulling it into a separate scene, but that would preclude colliding with other cars. Full rollback would allow that, but PhysX does not always play nice with rollback (certain behaviours become different when a scene has its state manually set)

slow monolith
#

seems like the only option lmao

#

I'd like to know what the AAA titles on unity use

#

like rust and tarkov

#

both great multiplayer experiences

floral turtle
#

not super familiar with either, do they have vehicles or mostly 3rd person character?

slow monolith
#

Rust does

#

I think tarkov is planned to

#

Rust cars use prediction too

floral turtle
#

rocket league is unreal, but it uses full rollback and prediction (bullet physics)

slow monolith
#

sounds like im going with full rollback then

floral turtle
#

rust uses raknet for the actual networking, not sure about the simulation layer

slow monolith
#

hmmm

jade glacier
#

You need resimulation for sure?

#

Games like RocketLeague go that route because they have a very specific case that makes interpolated states not an option.

#

I wouldn't get down the long deep rabbithole of making a system that tries to predict everything unless you really need it.

slow monolith
#

I mean the player needs to be resimulated

#

because its authoritative with prediction

#

Is there a way that I can ONLY re-simulate the player and not fuck up the physics completely in my game?

#

because if I pause the physics, and call physics.simulate a couple times in a loop on update(), won't the player be able to see the physics stopping for a second?

jade glacier
#

Nothing is paused. You don't resim in realtime.

#

You don't need to be deterministic for client prediction of you're game doesn't require 100% determinism. You can allow some tolerance for desync. Deterministic results make things a lot easier, but it isn't required for snapshot interpolation.

slow monolith
#

So how would I apply the re-sync

#

once it needs to occurr

jade glacier
#

You reset the state to what the server just said it was for that previous tick. And then quickly reapply all inputs and simulate back to current, like you are saying.

slow monolith
#

re-apply all inputs using physics.simulate?

#

all in a single frame?

jade glacier
#

The topic is more about a complete rollback with deterministic, vs just running a second simulation to resync some objects with the server.

#

You resimulate x ticks

slow monolith
#

The only real physics objects I'm going to have are players and cars

#

not much else

jade glacier
#

If you are in tick 20, and the server msg for tick 10 arrives, you compare the state of your predicted objects as they were on tick 10....

slow monolith
#

correct

jade glacier
#

You apply tick 10... And resim 10x

#

Depending on your game, that resim might only need a few objects involved.

#

Rather than a complete rollback of everything.

slow monolith
#

well physics.simulate forces all rigidbodies to update

#

so how would I avoid resimming some objects

jade glacier
#

You can run multiple physics scenes as needed

slow monolith
#

alright

#

is that not slow?

jade glacier
#

Not as slow as resimming an entire world of objects 10x

#

But again, the correct answer depends on your simulation and game architecture.

slow monolith
#

alright

#

so if the only rigidbodies I have are the players and the cars, It would just be better to resim on the main scene itself?

jade glacier
#

No idea

#

Depends on your game and what needs to be part of your desync correction

slow monolith
#

ok

sly fable
#

should i make copies of all my gameobjects for a multiplayer version using photon? aka using photonview components and scripts with photon.instantiate instead of gameobject.instantiate

#

or should i leave it the same for single player and just have it not connected to the network but leave the code and components as is

sly fable
#

for example Instantiate(playerPrefab, i.transform.position, i.transform.rotation); PhotonNetwork.Instantiate("Player", i.transform.position, i.transform.rotation);
should I want to use this in singleplayer should I have an if statement to seperate the two instantiations? so it picks the correct one?
is there a way with photon to do this automatically or do i have to address each instantiation with an if statement so it does the correct one

proven belfry
#

I m trying to implement mlapi into my project. I have afew questions though. Do i need to hire a server for dedicated rooms ? If so, how can i connect my project to the server ? Is it expensive to have a server which can has 50 people at same time ?

#

@everyone

slow monolith
#

Why on earth would you tag over 4,000 people

thorn hornet
#

OOOOF. Let's get into this brother.

#

That is legit dirty af

#

Why are you calling for it then using photon?

#

Maybe I'm not seeing something?

#

I'm reading that (and albeit I've been up all night doing things) But dude.... Instantiate Player and it's position and it's rotation? Then call on another instantiate? I don't even understand this.

weak plinth
#

DUKE

#

😄

#

I need some help fellas

#

I am using Photon 2 Pun, have 2 players spawning in

#

they seen to be swapping ownership for some reason on spawning in

#

Player 1 spawns in and is fine I can move him all normal, player 2 spawns in and starts controlling player 1, and player 1 now controls player 2

#

Upon investigation its showing the "IsMine" values as swapped

#

so its saying I own the other player and vice versa for whatever reason

#

Any ideas?

#

My ownership transfer is set to "Fixed" in the PhotonView

#

So I dont believe its that

proven belfry
rare storm
#

@weak plinth if (PhotonView.IsMine) { //ignore a script here, i forgot how to do it }

#

oh wait

weak plinth
#

yeah that I have

#

but the issue is its saying the players own eachother

#

once the second spawns in lol

#

like the isMine is true for eachother

#

and false for themself

#

its weird as hell

rare storm
#

i just woke up, sorry if im dumb if (! PhotonView.IsMine) { //ignore a script here, i forgot how to do it }

idk why this would work

weak plinth
#

that wouldnt work with abunch of players

#

would be abunch of falses lol

#

something is up

#

it should not be swapping ownership like it is

rare storm
#

i gotta get on my pc

somber drum
weak plinth
#

player 1 has an IsMine of true until player 2 joins

#

then when player 2 joins, player 1 has an ismine of false and he now owns player 2

#

and vice versa lol

#

and they now control eachother instead of themselves 😄

somber drum
#

Ask for help on the mlapi server.. It thats what you're using @proven belfry

somber drum
#

Ask less vague questions

proven belfry
#

@somber drum how to go mlapi server

somber drum
#

You try searching or nah

I have many servers grouped, literally easier for someone to search on google than me finding it btw

proven belfry
#

U could share a link or something

#

Anyway is it on discord?

somber drum
#

Yes

proven belfry
#

Thanks man

quick folio
#

is it hard to make the traffic like the one in GTA online ? all cars can be sync

sly fable
#

@thorn hornet no i was showing them both as an example for which one to use i wasnt going to use noth

#

both

#

i was asking if im in singleplayer mode should i just have an if statement separating the two different types of instantiations, or should i just make an entire new script one for multiplayer one for single player so i wont have to constantly check if its online or not

verbal lodge
slow monolith
#

I don't think that's how GTA does it regardless. Considering if you're in a car with a friend and you run over an NPC, it most likely won't show up on his screen (positions generated by the client, non authoritative server)

#

hence why it's so easy to hack on GTA

#

I'm very curious as to why they build their game like this. Perhaps the map itself is just too giant to be handled by a server? Or maybe there's too many players and it would be a waste of money to waste that much computing power making authoritative server lobbies

thorn hornet
#

Sorry, I went out like a light brother. Lemme see watcha got.

weak plinth
#

im using parrelsync and mirror and i keep getting a "called without an active client," it seems simple enough but I have no clue how to fix it

weak plinth
#

Has anyone here dealt with this error from Playfab authentication? "could not determine a title id for this"

#

I am using the playfab package, and I have the title ID and secret key added to the PlayFabSharedSettings

#

and I triple checked that they were correct

#

solved lol

slim ridge
#

quadruple checked?

white stone
proven belfry
#

Wow looks so nice

quick folio
proven belfry
#

Guys

safe lynx
#

hey im working on a self hosted MySQL server + php.

#

its up and working but i just want to make sure im not opening up my computer to bad stuff xD

#

i mean apart from the obvious and unpreventable like DOS attacks

slim ridge
#

keep an eye on your bandwidth usage

safe lynx
#

Fair enough is that it lol

#

I think I have my permissions setup right

#

Only accesses to the database from localhost are allowed

#

And the php scripts are obviously local host. So the only (hopefully) thing that’s public is those php scripts

#

And the php scripts have very strict rules on what it allows for input. And generally your not allowed to make changes to the database unless you have a token that’s generated when you login

#

And even if you have said token you’ll only be able to change the database that relates to your user account

#

Theoretically the worst thing someone can do is destroy their own user account

slow monolith
#

nobody is going to waste resources ddosing a random webserver for fun. One of my friends however made his SQL server public with no password and it got ransomware'd in like under 2 minutes

#

so keep that in mind @safe lynx

safe lynx
#

yea wdym making the server public Reeee

#

like if you go to the IP:85/phpmyadmin

#

it asks you for a username and password

#

ive made 4 accounts

#

anyone accessing from localhost has full access

#

anyone with my username and Password has full access

#

anyone with the other devs info has full access

#

and one last public account that only has SELECT access. (read-only)

#

so the people part of the playtest can see how everything works if they wanted to

#

but i dont understand how you could send get ransomware from that xD

#

but im planning on hosting it on a VM later anyways to stop anything bad from happening lmao

#

or host it on a spare computer

slow monolith
#

Making it public = port forwarding your router

#

so outside clients can access your private server

#

If you leave your username and password as root, it will get hacked in under 2 minutes by scanners

safe lynx
#

oh ive already port forwarded everything

slim ridge
#

there are robots out there that literally scan ip ranges all day every day and deploy attacks on open ports.

slow monolith
#

^

safe lynx
#

i forwared port 85 in this case

slow monolith
#

Better change the password from root

safe lynx
#

oh everything was changed from the start lmao

#

again look above^

#

afaik the only thing listening are those php scripts

#

those have to be public otherwise it wouldnt be possible lol

slow monolith
#

PHP really isn't unsafe

#

unless you're dealing with unsafe SQL queries

safe lynx
#

hmm what do you mean by that lol

slow monolith
#

sql injection

safe lynx
#

like allowing user input to directly affect the database?

slow monolith
#

like not escaping an sql query with user input in it

safe lynx
#

here leme get one of the current scripts

#

i can never remember where they are though lmao

slim ridge
#

he seems pretty determined, go for it bud

slow monolith
#

If a client can write his own input, and that input gets shoved in an SQL query

#

and you don't sanitize it for bad characters

#

then you will get hacked

#

thats the basis of SQL injection

safe lynx
#

alright here are two scripts. login and register user

#
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "CeaseVR";

//varaables submitted by user
$input = json_decode(file_get_contents('php://input'), true);
$Username = $input["Username"];
$PasswordHash = $input["PasswordHash"];

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM users WHERE username = '".$Username."'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
  // output data of each row
  while($row = $result->fetch_assoc()) {
    if($row["password"] == $PasswordHash){
        echo $row["userID"];
    }
    else {
        echo 0;
    }
  }
} else {
  echo 0;
}

/*
if ( $option == 1 ) {
  $data = [ 'a', 'b', 'c' ];
  // will encode to JSON array: ["a","b","c"]
  // accessed as example in JavaScript like: result[1] (returns "b")
} else {
  $data = [ 'name' => 'God', 'age' => -1 ];
  // will encode to JSON object: {"name":"God","age":-1}  
  // accessed as example in JavaScript like: result.name or result['name'] (returns "God")
}
*/
header('Content-type: application/json');
//echo json_encode( $data );

$conn->close();

?>```
#

login given a username and a password returns the user ID of said user in the database

slow monolith
#

yeah you're not sanitizing your inputs

#

thats gonna get you hacked

safe lynx
#

i see now i should do some cleaning of the inputs xD

#

how should i go about doing that?

#

obv the basics like max size allowed characters

slow monolith
#

mysql_real_escape_string($input["Username"])

#

something like this

#

instead of just $input['username']

safe lynx
#

but because its usernames in this case its going to be really unique

slow monolith
#

might have to use mysqli instead of mysql

safe lynx
#

im not really sure what im using tbh xD

slow monolith
#

mysqli_real_escape_string

#

with the example I provided above

safe lynx
#

what does that do precisely?

slow monolith
#

escapes the string

#

does some anti hacker stuff

safe lynx
slow monolith
#

If you allow raw strings in your SQL queries

#

without sanitizing them

#

people can run their own queries

#

such as drop all tables

#

and delete all your shit whenever they want

safe lynx
#

yea i see now how that could ruin everything

#

theres probably a bunch of other stuff i should try like disallow spaces

slow monolith
#

real escape string should do the trick

#

unless someone else has a different opinion

#

as long as you're not running dynamic javascript code from your database then you're fine

#

that's a whole other lesson

#

XSS injections

safe lynx
#

im eventually gonna try my hand at server side code but for now all the scripts are just going to be middle man scripts

#

oh also heres my register user script

#
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "CeaseVR";

//varaables submitted by user
$input = json_decode(file_get_contents('php://input'), true);
$Username = $input["Username"];
$PasswordHash = $input["PasswordHash"];

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT username FROM users WHERE username = '" . $Username . "'";
$result = $conn->query($sql);
$randomUserID = "0";
$returnStatement = "";
if ($result->num_rows > 0) {
    //tell user that name is already taken
    $returnStatement = "Username Taken";
} else {
  //Insert user in database
    $randomUserID = rand(0,999999999);
    $sql2 = "INSERT INTO users (userID,username, password, level, coins) 
    VALUES ($randomUserID,'" . $Username . "','" . $PasswordHash . "',1,100)";
    $sql3 = "INSERT INTO playercustomization (userID, nameColorR, nameColorG, nameColorB) 
    VALUES ( $randomUserID ,255,255,255)";
    if($conn->query($sql2)===true && $conn->query($sql3)===true ){
      $returnStatement = "User Registered";
    } else {
      $returnStatement = "Registered Failed";
    }
}
$data = [ 'status' => $returnStatement, 'userID' => $randomUserID];
header('Content-type: application/json');
echo json_encode( $data );
$conn->close();

?>
#

given a username and a password hash it creates a new user with a bunch of default user info

#

also i know to never store plain text passwords ever

#

thats another reason i wanted to make the database public readonly so people can see what information im actually storing

slow monolith
#

You're not checking for random user ID collisions

#

not a huge problem

safe lynx
#

yea its a very basic script so far xD

#

i was just gonna do big random numbers and hope they never overlap untill i spend a few hours making something else work lol

slow monolith
#

PHP also has built-in password hashing functions

#

never use MD5 or anything like that

#

you can bruteforce it extremely quick and I've seen it done on databases in realtime

safe lynx
#

ahh im doing the hashing at the client level

slow monolith
#

that should always be done on the server

#

client only sends raw password

safe lynx
#

y i though its bad to send raw passwords over the internet

slow monolith
#

Most of this is pretty much encrypted

#

unless im wrong about that

#

pretty sure there's some sort of encryption unless you misconfigured something

safe lynx
#

i dont see the problem with doing the hash at the game level

slow monolith
#

I'm coming down from a 3 day weed high so my brain is at like 5%

safe lynx
#

currently its just sha1 cause i dont know how to do something else

#

also damn i want to see what your gonna do at 100%

slow monolith
#

sha1 is too fast

safe lynx
#

should i swich to sha256

slow monolith
#

Use this

#

all hashes are different even if they use the same password

#

protects against hash tables

#

built into php

safe lynx
#

cool

#

ill look into it

#

also is there an easy way to do server side code using php or should i use c++

slow monolith
#

php is easy

#

I've never seen anyone make a website from C++

#

or anything except php

safe lynx
#

so if i clean the user inputs theres no harm in what im doing?

#

im still definitely planning on making a VM just for this to be safe but do i need to prioritize that now?

slow monolith
#

For sql injections, escaping the string like I showed you is pretty fine

#

However

#

Let me propose another problem to you

safe lynx
#

i dont want to just make a windows VM cause it seems wastefull but i dont know what else to use

slow monolith
#

User registers with any name he wants, makes his name <script>alert("HELLO WORLD");</script>

#

what happens when the client browser sees his name

#

client runs the code

#

thats dangerous because you can use javascript code like that, to grab the cookies of the client that the code is running on, and send it to a remote server that an attacker controls

#

now all of your clients have been hacked

safe lynx
#

first of all this is running in a untiy standalone .exe

slow monolith
#

session ID, not cookies

safe lynx
#

i dont know if unity or c++ will do that

slow monolith
#

I have no clue

safe lynx
#

but second im not really sure

#

i could do a max name length and dissalowed characters?

slow monolith
#

you'll need to disallow characters like that AND sanitize the input with regex on the backend

#

because if someone bypasses your front-end filter, it's not gonna do much

#

I actually think php has a built-in function for that hang on

safe lynx
#

deffinatly. also if you wondering im gonna lock down the register user script to require a single use token given when you buy the game

slow monolith
#

htmlspecialchars($string);

#

If I recall correctly

#

this will print that, without making the javascript run

#

so whenever you post comments or display usernames or shit, make sure they're run with that

safe lynx
#

i suppose but this is never gonna use a website to run the game xD

#

its in VR and im using textmesh pro for text rendering.

slow monolith
#

hmmm

safe lynx
#

i think your confused exactly what im doing

slow monolith
#

probably

safe lynx
#

im making a vr game and this is my solution for a database for the game to save information to

#

im using Photon for the P2P stuff

slow monolith
#

yeah then you only need to worry about sql injection

safe lynx
#

and to fix that you do said sanatize functions with some basic sanity cheaks

#

like dont allow anything longer than 30 char

#

cause regardless of how safe it might be its still shady af xD

#

also whats stoping someone from setting their username to SELECT blank

#

or whatever

#

wont that just cause a Sql error?

#

at worst

white stone
#

@quick folio Google traffic system unity

languid shuttle
#

can someone help me with photon converting these back to world space

#

with photon i guess u cant use transform as a parameter

#

so im having trouble in the final part because its giving me a error

#

top error

#

so yea i need to convert it to world space

grim violet
#

dont send rpc for the position with pun

#

use photonview an d observe a photon transformview

languid shuttle
#

but im trying to forcefully move

#

both players to a diffrent position

#

i ended up finding my issue because transforms dont convert to vector 3s in editor so i had to enter in stuff manually or

#

do something like this

#

start with my list of spawn points

#

then convert

crude spade
#

Can anyone pls help me I've added this network identity component and i get this

fast stone
#

Please tell me who some one knows about, photon ? i got animation problme with it.

small saddle
# fast stone

That usually means that the function "FlipFalse" is not on the same object your calling - for example, if your trying to do something like this:

public class Player : Mono
{
[PunRPC]
void SomeNetworkedFunc() { ... }
}

public class GameManager : Mono
{
void SomeFunc() {photonView.RPC("SomeNetworkedFunc", ...);}
}

In this case, "GameManager" is calling its local photonview, and not the one on "Player", and "SomeNetworkedFunc" doesnt exist on GameManager, so it cant find it - producing your error

fast stone
#

Well, ok i will take a loook thank u so much

#

Bleh still i dont have idea... haha

#

all the things is on the right ,gameobject

#

@small saddle can i get more help from u ?

#

or this is not possible

small saddle
fast stone
#

Bro...

#

im sooooooooooo

#

on false dont have [PunRPC] before

fast stone
#

@small saddle one more, problem, run animation , looks nice and work nice but feels like a lagged'' telepport''

rare cliff
#

I'm having trouble with ClientWebSocket, and this is really stumping me. It can connect to the server, and I see the connection/disconnection, but after connecting I get the following exception at a 1sec interval:

SocketException: No connection could be made because the target machine actively refused it.

But, when I connect to the same websocket server using a browser, it connects and sends messages just fine.

Also, additional note: The same ClientWebSocket code, when changing to wss://echo.websocket.org has the same error as my custom websocket server, and again works fine in browser on the same machine.

small saddle
# fast stone <@!168578802421727232> one more, problem, run animation , looks nice and work ni...

Not sure what you mean? That could probably be the actual animation itself, I dont see why that would be "laggy" on the network, if anything it might be delayed before it plays (unless thats what you are referring to)

Also as a side note, you actualy could combine those 2 RPC's into one, and pass in a param, for example:

[PunRPC]
void Flip(bool isFacingRight)
{
sr.flipX = isFacingRight;
}

void SomeFuncThatCallsYourRPC()
{
howeverYourAccessingYourPhotonView.RPC("Flip", ..., true);
}

The third param is technically supposed to be a new object[] { whatever you need to send over the network } but if its only 1 param, it will automatically treat it as that anyway, so instead of "true" you can specify the condition that determines your flipX value - just reduces the number of messages your generating and cleans up your net code a little

amber trench
#

is there a photon way to join a lobby with a shared code?

#

like in among us or other multiplayer mobile games

small saddle
small saddle
# amber trench is there a photon way to join a lobby with a shared code?

AFAIK not natively, but what I did is store the room code/password as a string in the rooms CustomProperties, retrieved it and then compared the players entered code from a input field to that rooms custom properties "password", if it matches connect them to the room, if not display an error

amber trench
#

Got it

#

Thank you

mossy goblet
#

New to multiplayer in Unity. I have a NetworkManager set up with my player prefab attached. I have a NetworkIdentity on the root object of my player prefab and my player movement script is attached to said root object and I'm trying to use "isLocalPlayer" but it's giving me an error in the console

#
UnityEngine.Networking.NetworkBehaviour:get_isLocalPlayer()
PlayerMovement:Update() (at Assets/Reid's FPS Controller/PlayerMovement.cs:21)```
#

Not sure what I need to do

#

Don't know which object it's referring to

#

Oh and I also get this error in the console

#
UnityEngine.Networking.NetworkBehaviour.get_isLocalPlayer () (at Library/PackageCache/com.unity.multiplayer-hlapi@1.0.8/Runtime/NetworkBehaviour.cs:91)
PlayerMovement.Update () (at Assets/Reid's FPS Controller/PlayerMovement.cs:21)```
sly fable
#

whenever I start my multiplayer photon room some objects are not set to active for some reason
do i have to instantiate every prefab across the network instead of having this object in the scene

hollow chasm
#

PHOTON

Alright so I got a problem with the OwnerShip of a room, whenever the owner does the action it works fine but for the other players, the script doesn't work and it applies to the owner.
Ex : When a player goes to another room, the Owner cannot see himself in the room, he sees the player that just entered in a new room.
I'll leave the script here.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RoomScript : MonoBehaviour
{
    [SerializeField] public GameObject virtualCam;
    [SerializeField] public PhotonView PhotonView;

    void OnTriggerEnter2D(Collider2D other){
    if (PhotonView.isMine == true){
        if(other.CompareTag("Player") && !other.isTrigger)
        {
            virtualCam.SetActive(true);
        }
    }
}
    void OnTriggerExit2D(Collider2D other){
    if(PhotonView.isMine == true){
        if(other.CompareTag("Player") && !other.isTrigger) 
        {
            virtualCam.SetActive(false);
        }
     }
    }
}```

It also gives me this error ``The observed monobehaviour (Room1) of this PhotonView does not implement OnPhotonSerializeView()!``
sly fable
#

@hollow chasm are both players instantiated over the network/ have photonviews?

fast stone
#

@weak plinth Thank u ❤️

hollow chasm
weak plinth
#

@fast stone wrong ping bro

sly fable
#

are all the players in the scene? or did you instantiate them?

hollow chasm
#

I instantiate them

sly fable
#

how do you instantiate them?

#

drop the code

hollow chasm
#

PhotonNetwork.Instantiate(PlayerPrefab.name, new Vector2(this.transform.postion.x * randomValue, this.transform.postion.y))

mossy goblet
#

Bruh

sly fable
#

im shit with networking

mossy goblet
#

me too

#

I need mf help ;-;

sly fable
#

whats ur issue man

mossy goblet
#

I'll rpeost it

#

New to multiplayer in Unity. I have a NetworkManager set up with my player prefab attached. I have a NetworkIdentity on the root object of my player prefab and my player movement script is attached to said root object and I'm trying to use "isLocalPlayer" but it's giving me an error in the console

UnityEngine.Networking.NetworkBehaviour:get_isLocalPlayer()
PlayerMovement:Update() (at Assets/Reid's FPS Controller/PlayerMovement.cs:21)```
Not sure what I need to do
Don't know which object it's referring to
Oh and I also get this error in the console
```NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Networking.NetworkBehaviour.get_isLocalPlayer () (at Library/PackageCache/com.unity.multiplayer-hlapi@1.0.8/Runtime/NetworkBehaviour.cs:91)
PlayerMovement.Update () (at Assets/Reid's FPS Controller/PlayerMovement.cs:21)```
patent fog
#

show line 21 of PlayerMovement script

#

lokks like an unassigned reference

#

looks*

#

fix reference error and NetworkIdentity should be found and fixed

silent zinc
#

Hi guys, i have a networking question, what are the best approaches when dealing with a multiplayer game based on udp? I'll be more specific...i have this client method for receiving... ```cs
public static void RecvPacketSync()
{
try
{
if (client != null)
{
if (client.Client != null)
{
if (client.Client.Connected)
{
byte[] buffer = client.Receive(ref selfEndpoint);
if (buffer != null)
{
if (buffer.Length > 0)
{
ProcessBuffer(buffer);
}
}
}
}
}
}
catch (Exception e)
{ Debug.Log(e.ToString()); }
}

subtle gale
#

Are there many opinions on using mirror vs photon vs forge?

#

For context, I'm mostly looking for something that supports networked physics

#

or at least allows for a low enough level of sending packets alongside the framework that I could implement snapshots myself

rare cliff
#

OK, so after trying out three different WebSocket implementations, I can't create a client app because I can't connect to any servers. I get the exception:

SocketException: No connection could be made because the target machine actively refused it.
Rethrow as WebException: Error: ConnectFailure (No connection could be made because the target machine actively refused it.

I don't have a firewall on my PC. There's no firewall rules setup on the router. I can't connect to local, localhost, or ws://echo.websocket.org.

BUT, using a browser and JS I can connect to all, without error

I'm stuck, and could really use some advice. I need to get my wheels out of this rut ASAP, because it's blocking my development

subtle gale
#

@rare cliff which websocket libraries are you using? or do you have your own retry loop for connection?

rare cliff
#

I've tried wrappers for .NET's WebSocket, two flavors specific to Unity, and websocket-sharp which has no external dependencies and is a custom implementation

#

I've used these before, years ago. I'm not sure why it's not working now

#

It connects, and I can see the Connect/Disconnect on the server. It just throws that error every second after initiating the connection

#

I also can't send/receive data correctly

subtle gale
#

are you using windows?

#

or linux/macos

rare cliff
#

@subtle gale Windows 10, Unity 2020.1.5f1

#

If I use the same websocket-sharp DLL in a standard .NET 4 Console project, I can connect, send/receive messages without issue

#

(same code too, just a copy and paste)

subtle gale
#

huh

rare cliff
#

No, this is just running in editor

subtle gale
#

@rare cliff if you want, I could try building it on my machine

#

if that works narrows it down to environment configuration probably

rare cliff
#

I'll send you the class and DLL in a minute, thanks

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NetworkManager : MonoBehaviour
{
    WebSocket websocket;



    async void Start()
    {
        websocket = new WebSocket("wss://echo.websocket.org");

        websocket.OnOpen += (sender, e) =>
        {
            Debug.Log("Connection open!");
        };

        websocket.OnError += (sender, e) =>
        {
            Debug.Log("Error! " + e);
        };

        websocket.OnClose += (sender, e) =>
        {
            Debug.Log("Connection closed!");
        };

        websocket.OnMessage += (sender, bytes) =>
        {
            //Debug.Log("OnMessage!");
            //Debug.Log(bytes);

            // getting the message as a string
            var message = System.Text.Encoding.UTF8.GetString(bytes.RawData);
            //var message = bytes.Data;
            Debug.Log("OnMessage! " + message);
        };

        // waiting for messages
        websocket.Connect();

        // Keep sending messages at every second
        //InvokeRepeating("SendWebSocketMessage", 0.0f, 1f);
    }

    async void SendWebSocketMessage()
    {
        if (websocket.ReadyState == WebSocketState.Open)
        {
            // Sending bytes
            //await websocket.Send(new byte[] { 10, 20, 30 });

            // Sending plain text
            websocket.Send("plain text message");
        }
    }

    // Update is called once per frame
    void Update()
    {

    }

    async void OnDestroy()
    {
        CancelInvoke();
        websocket.CloseAsync();

        websocket = null;
    }
}
#

I'm also downloading different versions of Unity. This wouldn't be the first time in the last... oh, week or so, that I've had to change the point release for an obscure barely documented issue that fails on one specific point release

subtle gale
#

@rare cliff seems to work for me but I did have to change the url to ws://... rather than wss:// and remove the async function portions

rare cliff
#

What version of Unity?

subtle gale
#

2020.2.0f1

rare cliff
#

Yeah, I've got them downloaded. I'm going to test different versions in a bit

rare cliff
#

@subtle gale Was that in editor or did you try a runtime build?

subtle gale
#

in editor

rare cliff
#

Yah, 2020.1.7f1 no dice. Trying 2020.2.1f1 now

#

Did you use .NET 2.x or 4.x?

subtle gale
#

.NET 4.x i believe

rare cliff
#

Hm, getting the same behavior on 2020.2 as well

subtle gale
#

do you have fiddler installed or any other kind of packet sniffing stuff?

#

ive had weird connection issues with them in the past

rare cliff
#

Hm, so if I make an empty 2020.1.17f1 project, it works 🤔

#

Derp, it was a component that was failing an HTTP call on an interval, but just coincided with the time I implemented Websockets. The stacktrace didn't give me the root calling component, so I had assumed it was Websockets 😛

#

So, that wasted a whole day of my time because I couldn't access the whole calling stacktrace to see what originated the call

#

System.Net.Sockets.SocketAsyncResult.CheckIfThrowDelayedException () (at <aa976c2104104b7ca9e1785715722c9d>:0)
System.Net.Sockets.Socket.EndConnect (System.IAsyncResult asyncResult) (at <aa976c2104104b7ca9e1785715722c9d>:0)
System.Net.Sockets.SocketTaskExtensions+<>c.<ConnectAsync>b__2_1 (System.IAsyncResult asyncResult) (at <aa976c2104104b7ca9e1785715722c9d>:0)
System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) (at <9577ac7a62ef43179789031239ba8798>:0)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <9577ac7a62ef43179789031239ba8798>:0)
System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () (at <9577ac7a62ef43179789031239ba8798>:0)
System.Net.WebConnection+<Connect>d__16.MoveNext () (at <aa976c2104104b7ca9e1785715722c9d>:0)
Rethrow as WebException: Error: ConnectFailure (No connection could be made because the target machine actively refused it.

That was the exception... No way to identify what was calling it. Again, what a shit cursed coincidence

subtle gale
#

oof

rare cliff
#

FML this week, really

silent zinc
#

Is it better to do the parsing of a status packet in the Update() or in a separate thread?

subtle gale
#

@rare cliff well at the very least it is a learning experience

rare cliff
#

@silent zinc I generally try to queue things, and then handle them on the main thread. You can parse it, but only if it's never reading data outside the packet

#

So, I'll make a thread safe queue of things, and then go through that queue when the main thread loops around

silent zinc
#

yes ok, but like, is it better in terms of perfomance?

rare cliff
#

Dunno, but it's better in terms of data layout and async calls

silent zinc
#

Parsing every packet and updating the character in the Update i mean

#

in game

rare cliff
#

Likely more efficient, but you'll have to test on your specific use case

subtle gale
#

I would assume it would just be more efficient based off caching

#

but profiling trumps all usually imo

subtle gale
#

Is Photon Quantum ever going to become more accessible to hobbyists?

gleaming prawn
#

Maybe, maybe not... the new photon fusion will for sure

#

Quantum requires a lot more commitment as it is a multiplayer game engine where unity is a view/ui engine “only” (also used for level design). It’s not only the pricing but the fact that you need to really have a clear goal to finish a game, etc.
It’s a steeper learning curve that pays off if you have a game that maps clearly to the approach (deterministic predict rollback).

#

We’ve opened to revenue share deals and are still willing to discuss these options with special cases whenever it makes sense.

#

But as a general free tier to hobbyists to download and try its a bit more involved due to all I explained.

#

Feel free to send us an email if you have something in mind where it clearly is the best option.

subtle gale
#

I see, is there much new information about fusion? Haven't really seen much about it past an email + a forum thread

gleaming prawn
#

And as I said, the new Photon fusion that will replace both bolt and pun will have several tiers and options

#

Not yet, but we’re very close to start the alpha with some selected teams

#

I can’t say the exact date, but it’s very close

#

It’s this month still...:) for a public release I can’t share anything yet

#

But fholm has been streaming about networking (he pasted links here every day he streams) and he talks about it a lot

#

He’s the lead developer again (also quantum and bolt)

subtle gale
#

cool stuff, thanks for the answers 🙂

gleaming prawn
#

Yw

silent zinc
#

Can anybody help me? It's related to the previous question, now my parsing code is done in Update(), the result seems pretty much improved, but still it is not the same as the playing character...what could i possibly doing wrong?

#
private void SendStatusThread()
{
    try
    {
        while (isActive)
        {
            if (LastStandGameManager.hasStarted)
            {
                if (canWriteStatus)
                {
                    canWriteStatus = false;
                    Client.SendPacket(playerStatusPacket);
                }
            }
        }
    }
    catch
    { }
}

    
private void WriteStatusThread()
{
    try
    {
        statusN = 0;

        while (isActive)
        {
            if (LastStandGameManager.hasStarted)
            {
                if (!oldStatus.isEqual(status))
                {
                    statusN += 1;

                    oldStatus = status.Copy();

                    playerStatusPacket = new PlayerStatusPacket(status, statusN);

                    canWriteStatus = true;
                }
            }
        }
    }
    catch
    { }
}
``` these are two threads that handle the player status, and send it to server.
#

am i doing something wrong in the protocol?

#

what are the main cause of character not updating in 60 fps like the playing character? Like, it seems that the protocol is stable, looking at the debug logs of server/client.

#

But clearly something is taking too much time to process...

grim violet
#

those are not threads, they are just method

#

protocol should be udp

#

not sure what cause your character to not update 60 fps i dont understand your question

silent zinc
#

yes sorry they are the methods attached to the thread run

grim violet
#

are you waiting for the packet to be received before moving the player

silent zinc
#

which player?

grim violet
#

i dont know what you are doing

#

what packet are you sending and receiving? just a number?

silent zinc
#

i'm sending a status class that has attributes of the player, floats and bools, and the packet has this structure : headerByte + BodyLength + Body

grim violet
#

why do you say its not updating 60 fps ?

#

what isnt updating?

silent zinc
#

the opponent

#

like it's in almost 30 fps

grim violet
#

its updating when it receive data, but dont expect data to be sent 60 time a second and received the same way, there can be error, data lost, lag

#

how do you know its updating at 30 fps instead of 60

#

if you arent moving anything

silent zinc
#

ok i'm doing this in game, i'm sending the status packet only if the status has changed, the server just send that packet without worrying about being received

#

I have a receive protocol, like another packet for telling the other side that it has been received

#

which i'm still testing

grim violet
#

should always expect a delay

#

60 fps is 16.7ms second, i dont believe the ping itself is under 30ms

silent zinc
#

on localhost???

grim violet
#

well not local host no

silent zinc
#

lol

grim violet
#

there still some execution time and all

#

i dont nknow what is all behind it

silent zinc
#

what do you need to know?

#

Could you help me please?

grim violet
#

still trying to figure out what you trying to do lol, but no i probably cant help you
been a while i didnt play with socket directly, im using third party which have thought of all problems already ;p

#

one thing is sure you cant send a packet every frame

#

and exspect it to be received at same pace

silent zinc
#

that's why i'm ignoring the previous packet, and sending the next right away when the status change

grim violet
#

packets are not received in order in udp too

#

unless u mark them

#

like if you receive packet 48 then 46 you ignore 46

silent zinc
#

i'm assign to every packet a ulong

#

that gets increased when the status change / sending the packet

#

so like even the server, store the previous status N and if the next packet has not N greater than previous, it will reject it, same in client side

fast stone
#

someone ?

grim violet
#

is something not showing properly in the game?

silent zinc
#

ehm no, cause i just have the characters, everything plays fine for now, but the character moves not smooth like the playable one.

grim violet
#

Kio if you are observing your own component you need to implement that method

#

are you lerping the movement? there must be some trick like telling character to move in a direction and not stop until you got that other packet telling you to stop, you have to predict in some way the direction its going to not have hitching like this

#

i dont know the exact process thought

fast stone
#

@grim violet uh ok,

silent zinc
#

in the PlayerComponent attached to the character, if it is the Opponent, then do this in Update() ```cs
gameObject.transform.localPosition = new Vector3(status.positionX, status.positionY, 0);

fast stone
#

@grim violet i just follow tutorial ,and im scary if i look this man dont have that, i have same code and something not working

grim violet
#

yeah there no lerping in that steve

#

its just drastically setting the position

silent zinc
#

isn't that the best approach for a 2D game? :/

grim violet
#

Kio you have to extend your class with IPunObservable, then create a method like this

#

look at bottom

#

2d game i lerp my movement

#

just like 3d

silent zinc
#

i tried to pass the axis force values instead, but it isn't precise at some point...

grim violet
#

or it wont move smoothly

fast stone
#

Ok Devil, but more i asking how for this man can work it

#

sorry for my english can be rly bad

silent zinc
#

isn't lerping using the force values instead and moving the character with the same controller?

#

shit

#

it WORKS!

grim violet
#

black magic

fast stone
#

eh i cant fix it

#

;c

grim violet
#

Kio use photon tutorial and example

#

demo example that come with that probably have it implemented somewhere so you can look at it

silent zinc
#

@grim violet isn't lerping using the force values instead?

grim violet
#

what force

#

if you physic you use AddForce to move character

silent zinc
#

sorry, the Input 's force axis

grim violet
#

not sure what that is

#

seem to be for joystick to move slow of fast depending of pressure

#

you have to calculate that somehow with your movement

silent zinc
#

yeah it's basically the value of Input manager X and Y axis

grim violet
#

yeah, you gotta calculate that with the lerp and all

#

i suck at math i cant give you the code on that

#

lol

#

probably all around the web thought

silent zinc
#

what happens if i use the same AddForce with the input values?

#

i mean, for now it seems to work

grim violet
#

addforce will use physic to move your character

#

you probably just want that locally

silent zinc
#

why?

grim violet
#

if you start moving other player with addforce it might get weird result

#

you move with add force and send your own packet that way