Looking at https://doc.photonengine.com/en-us/pun/v1/demos-and-tutorials/package-demos/rpg-movement, it seems to have clients determine speed using last position and current position. Perhaps that's the suggested way.
On my player movement, my speed is calculated based on input and how far I tell the controller to move, so it will be a bit different, but perhaps I can make it work
#archived-networking
1 messages · Page 89 of 1
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 Don't cross post your question
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.
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
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.
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
How can i cloud save for free(non google services)??
these are paid services for a reason
I don't know of any way to make commercial cloud saves, for free
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
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?
I couldn’t see why not?
If you need to do it for it to work than you should be able to do it
iam scared bc google might suspend the acc
i know how to do it and it is easy
but iam just super scared
@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.
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?
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
Yes, this isn't an issue or anything from google's side, but, most people using mobile internet are behind a CGNAT ie they are sharing public IPs so you can't listen to incoming connections from their devices
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
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!
is connectionId something assigned once connected?
yea i think its automatically assigned https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Networking.NetworkConnection-connectionId.html
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
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
{
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?
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.
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.
@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?)
@tawdry pike Do you have an idea for this?
You could debug the code and see what 'this' is in RoomManager.Instance = this below the destroy.
@tawdry pike I don't know what to do 🙂
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.
Ah, I think I can answer my own question: https://doc.photonengine.com/en-us/pun/current/lobby-and-matchmaking/userids-and-friends
Photon Unity Networking framework for realtime multiplayer games and applications with no punchthrough issues. Export to all Unity supported platforms, no matter what Unity license you have!
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
Is it hard to implement google services in game and save variables in to cloud?
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.
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).
Update: problem solved. Using Visual Studio 2019 instead of vscode.
How many FPS should my unity based server run at
is 30fps enough? I have to do physics simulations btw
Depends on the game you are building
first person shooter
VS Code has issues with Unity, that comes up often @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.
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?
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.
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
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)
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.
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?
https://assetstore.unity.com/packages/tools/network/netopt-game-network-optimizer-165466#description
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.
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.
thank you so much, I'll take this with a grain of salt then and do some research
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.
https://github.com/emotitron/BitpackingTools They all kind of do the same thing.
does anyone know any videos where i can learn how to make multiplayer (I know nothing about multiplayer btw)
youtube: "unity photon tutorial" or "unity mirror tutorial"
google: "networking in unity"
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
Not sure about hole punching but I used this library for creating a DNS Server right in Unity:
https://github.com/kapetan/dns
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)
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
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.
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
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
This is all for the server btw
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
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.
Not really if you don't ask the actual question
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.
So...?
You recompiled your code while playing it looks like. That always breaks stuff.
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.
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.
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 🤷
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 🙂
Left side is the Client and Right side is the Server
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
I have found the issue and fixed it. It was SO simple this is so frustrating.
Regardless thanks for the help 🙂
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
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
oops, sorry, was confusing this with another conversation I was having in a different channel about Unity crashing. Nm.
NP just had 3 hours taken from my life lol
Leave and learn I guess
I think its very good way, I have now similar solution, 4 types independent servers, this is my old video https://youtu.be/bN7hVENcFFk
Thanks I am gonna watch the video
Hello I'm making a multiplayer game using unity now and in server section I use socket io and node js
the unity package that I use for socket io is https://github.com/fpanettieri/unity-socket.io-DEPRECATED
I had a problem getting for parsing json array
my json array structure is like 👇
GitHub
Socket.IO client for Unity3d. Contribute to fpanettieri/unity-socket.io-DEPRECATED development by creating an account on GitHub.
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?
i'm interested in firebase too. just discovered it late last night. i'd love some developer opinions on it
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 🤯
is 'gamesparks' and 'pgp' technically a networking thing or is there a better channel to discuss these things?
Anything network related fits in here.
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.
if you go with gamespark make sure you need all those features yea
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?
Best to just post the questions. People will just ignore it if they don't have an answer for you. @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?
I would join the Mirror discord and ask that, they will have better Mirror specific answers.
ok cool, thanks
just check "server build" in build options
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.
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
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.
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?
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
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/
That is out of Beta @slim ridge Simple is part of Pun2
The current Pun2 on the asset store has it built in.
{
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?
Should I just queue up velocity events and only execute one per gameobject per fixed timestep?
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?
Any networking for unity5x?
I think PUN classic still officially supports Unity5, but I might be wrong.
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.
if you want a two-way connection you can use a simple TCP protocol.
otherwise polling is a practical and efficient solution
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
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?
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
i can net work yay
@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?
#💻┃code-beginner Scene scripts must inherit from MonoBehaviour
This class inherits from mono behaviour, so should be fine
Is there another@compilation error?
and i think i made everything fine
no
so...?
@oak flower
@gleaming prawn
So did you research/debug the problem further?
what do You mean?
Sorry, off with family now
Ok
@weak plinth Share the tutorial you followed and received the error so others can see if the error reproduces.
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...
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
Someone know a tutorial for univoice ? Or knows any way to have p2p local voice chat ?
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
@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 Read the pinned docs for starters
@outer hinge Make sure to check out the official Mirror discord
No one will say use this and do this and thats the answer, way to many variables come into play
so are we recommending DOTS now? Last time I checked it was still too early
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
thx for the reply! I'll try that out and check on the Mirror discord too
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.
nice, that's good to know! I will check out those libraries! Thanks a ton!
note that while Unity Physics is advertised as deterministic, it's not currently deterministic cross platform (ios, android, etc), and you also need to ensure that your entire game loop is determ too
so it's not a ready to go system like Photon Quantum
Oh thanks for the info. Apparently Burst is breaking that determinism based on a few forum posts.
@outer hinge if you werent able to fix dm me and I gotcha bud
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.
so if im making a game that isnt cross platform i can just use the normal unity physics and itll still be deterministic, right?
no, PhysX will not be determ cross platform (or even between intel/amd)
oof
do you need determinism? It can be a huge investment to make a game deterministic, even beyond physics
yeah
what genre is it?
if it's a pretty standard fighting game, you probably don't need a full physics engine
i just need to figure out collisions and then ill be pretty much done with it
IIRC DOTS Physics actually is deterministic between Intel and AMD
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
you can google around a bit, but stuff like sphere-sphere and box-box collisions are pretty straightforward. There's also things like this: https://assetstore.unity.com/packages/templates/systems/ufe-2-pro-125472#description
(I haven't vetted that asset)
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
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
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
I think collision itself not being deterministic won't matter if all the movement is deterministic
if you're doing it for online, where you send inputs only (not the state of objects), you'll get into an edge case where on one peer the collision is detected, and on another it is not (due to the very slightly divergence between the collision calculattions), resulting in the entire thing desyncing
oh
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?
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?
its like 100$ for 5 year for 100 ccu with photon, not that much really
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
is unity ever going to come out with unity networking
Unity currently is working on two networking packages, the MLAPI that they acquired and NetCode, which is DOTS only
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.
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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.
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.
@marble viper Read the pinned docs for starters, read this entire thread, way to hard to pinpoint exactly one asset.
ok
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.
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
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
read above, someone mentioned 100 for $100 5 years
Do you know how among us does their server rooms?
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 check https://steamworks.github.io/
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!
Ive no idea, have you tried the unity forum as well
I have this networking class...https://hatebin.com/wqcatjwmva
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
this is my Packet class : https://hatebin.com/feihrqdtrb
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
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.
i have 2020.1.17
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
Or would I have to use the character controller
if I'm using physics, am I going to need to use physics.simulate?
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
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.
I'm live at http://twitch.tv/fholm
I have a question, randomly while I was using localhost to connect to my own computer it stopped working dose anyone know why?
@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
Are you following fholms stream
?
He’s building something from scratch and will cover most of these topics
No I am not
Server reconciliation assumes you track time or ticks on both server and client
And on client you store an input buffer.
Yep thats all do-able
When client receives server data, snaps it and resimulate forward with the input buffer
Re-simulate with physics.simulate?
You do not interpolate simulation. You interpolate visuals
What about all of the other rigidbodies moving in the scene?
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
so it would be way easier to use a character controller instead of rigidbody
for the character
If you use a stateless@physics, it’s easier
Yes, that’s is one of the goals@of a kcc
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
Yes, you can. But the unity@one is quite heavy, be advised
hmm alright
There’s one called KcC that people say it’s better
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
ok
And remember, you need a tick system before any of that
Or at least proper timestamps
alright
You don’t add reconciliation, you build a system that has that built in
What's the point of a kinematic rigidbody though? Isn't that just the same thing as transforming a regular object?
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
Still very confused. Could you give a quick example?
But the kcc itself@would also be fine without determinism
Sorry, typing from phone
Putting kid to sleep
alright
Also I'm going to have cars in my scene, for which I will need dynamic rigidbodies with reconciliation
right?
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
So you're telling me I'm going to need something like photon in the end?
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
alright
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?
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
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?
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
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
Yes, exactly
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
You step multiple times in one single update
Player only sees the final result
You also need to interpolate the visuals
And then I would just sleep the other cars that were moving
I really suggest you watch fholm streams
until the simulation is done?
There are several topics you are mixing which are required to work together
alright ill have a look. thanks
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
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
I'm a bit of a moron, so you'll have to explain this as if you were talking to a 10 year old
@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
also—is server authority necessary? Can be easier to just give clients authority of their char if you aren't worried about cheating
Server auth is necessary, and I'll need to use dynamic rigidbodies because of the cars
someone suggested full rollback
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)
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
not super familiar with either, do they have vehicles or mostly 3rd person character?
rocket league is unreal, but it uses full rollback and prediction (bullet physics)
sounds like im going with full rollback then
rust uses raknet for the actual networking, not sure about the simulation layer
hmmm
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.
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?
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.
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.
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
The only real physics objects I'm going to have are players and cars
not much else
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....
correct
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.
well physics.simulate forces all rigidbodies to update
so how would I avoid resimming some objects
You can run multiple physics scenes as needed
Not as slow as resimming an entire world of objects 10x
But again, the correct answer depends on your simulation and game architecture.
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?
ok
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
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
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
Why on earth would you tag over 4,000 people
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.
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
i wanted to make sure that everyone read this. So i might get a quick help. It didn't work though.
@weak plinth if (PhotonView.IsMine) { //ignore a script here, i forgot how to do it }
oh wait
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
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
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
i gotta get on my pc
Quite selfish of you, people are busy- great way to get no help is pinging everyone lol
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 😄
Ask for help on the mlapi server.. It thats what you're using @proven belfry
Dude still no help
Ask less vague questions
@somber drum how to go mlapi server
You try searching or nah
I have many servers grouped, literally easier for someone to search on google than me finding it btw
Yes
Thanks man
is it hard to make the traffic like the one in GTA online ? all cars can be sync
@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
You can find the link to the MLAPI discord in the pinned messages of this channel.
Thanks
I'm planning on making the same thing. All car positions need to be handled on the server
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
Sorry, I went out like a light brother. Lemme see watcha got.
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
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
quadruple checked?
@quick folio check out road and traffic system https://assetstore.unity.com/packages/templates/systems/road-traffic-system-21626
Wow looks so nice
i ve tested this asset performance, really not what i expected , the performance so bad
Guys
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
keep an eye on your bandwidth usage
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
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
yea wdym making the server public 
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
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
oh ive already port forwarded everything
there are robots out there that literally scan ip ranges all day every day and deploy attacks on open ports.
^
i forwared port 85 in this case
Better change the password from root
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
hmm what do you mean by that lol
sql injection
like allowing user input to directly affect the database?
like not escaping an sql query with user input in it
here leme get one of the current scripts
i can never remember where they are though lmao
he seems pretty determined, go for it bud
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
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
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
mysql_real_escape_string($input["Username"])
something like this
instead of just $input['username']
but because its usernames in this case its going to be really unique
might have to use mysqli instead of mysql
what does that do precisely?

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
yea i see now how that could ruin everything
theres probably a bunch of other stuff i should try like disallow spaces
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

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
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
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
ahh im doing the hashing at the client level
y i though its bad to send raw passwords over the internet
Most of this is pretty much encrypted
unless im wrong about that
pretty sure there's some sort of encryption unless you misconfigured something
i dont see the problem with doing the hash at the game level
I'm coming down from a 3 day weed high so my brain is at like 5%
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%
sha1 is too fast
should i swich to sha256
Use this
all hashes are different even if they use the same password
protects against hash tables
built into php
cool
ill look into it
also is there an easy way to do server side code using php or should i use c++
php is easy
I've never seen anyone make a website from C++
or anything except php
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?
For sql injections, escaping the string like I showed you is pretty fine
However
Let me propose another problem to you
i dont want to just make a windows VM cause it seems wastefull but i dont know what else to use
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
first of all this is running in a untiy standalone .exe
session ID, not cookies
i dont know if unity or c++ will do that
I have no clue
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
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
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
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.
hmmm
i think your confused exactly what im doing
probably
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
yeah then you only need to worry about sql injection
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
@quick folio Google traffic system unity
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
dont send rpc for the position with pun
use photonview an d observe a photon transformview
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
Can anyone pls help me I've added this network identity component and i get this
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
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
Where are you calling your RPC, and where does the RPC/function itself actually exist?
@small saddle one more, problem, run animation , looks nice and work nice but feels like a lagged'' telepport''
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.
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
is there a photon way to join a lobby with a shared code?
like in among us or other multiplayer mobile games
I dont think thats your animations, that looks like the position itself, possibly the "teleport at distances larger than" value is set too high, or your PhotonNetwork.sendRate is too low if you modified it (and I would be careful about modifying the sendRate, as itll add more messages per min/more network traffic to your room)
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
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)```
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
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()!``
@hollow chasm are both players instantiated over the network/ have photonviews?
@weak plinth Thank u ❤️
The player prefab has a photonview
@fast stone wrong ping bro
are all the players in the scene? or did you instantiate them?
I instantiate them
PhotonNetwork.Instantiate(PlayerPrefab.name, new Vector2(this.transform.postion.x * randomValue, this.transform.postion.y))
Bruh
im shit with networking
whats ur issue man
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)```
show line 21 of PlayerMovement script
lokks like an unassigned reference
looks*
fix reference error and NetworkIdentity should be found and fixed
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()); }
}
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
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
@rare cliff which websocket libraries are you using? or do you have your own retry loop for connection?
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 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)
huh
are you building for the webplayer by chance? https://docs.unity3d.com/530/Documentation/Manual/SecuritySandbox.html
The Unity Manual helps you learn and use the Unity engine. With the Unity engine you can create 2D and 3D games, apps and experiences.
No, this is just running in editor
@rare cliff if you want, I could try building it on my machine
if that works narrows it down to environment configuration probably
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
@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
What version of Unity?
2020.2.0f1
Yeah, I've got them downloaded. I'm going to test different versions in a bit
@subtle gale Was that in editor or did you try a runtime build?
.NET 4.x i believe
Hm, getting the same behavior on 2020.2 as well
do you have fiddler installed or any other kind of packet sniffing stuff?
ive had weird connection issues with them in the past
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
oof
FML this week, really
Is it better to do the parsing of a status packet in the Update() or in a separate thread?
@rare cliff well at the very least it is a learning experience
@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
yes ok, but like, is it better in terms of perfomance?
Dunno, but it's better in terms of data layout and async calls
Likely more efficient, but you'll have to test on your specific use case
I would assume it would just be more efficient based off caching
but profiling trumps all usually imo
Is Photon Quantum ever going to become more accessible to hobbyists?
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.
I see, is there much new information about fusion? Haven't really seen much about it past an email + a forum thread
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)
cool stuff, thanks for the answers 🙂
Yw
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...
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
yes sorry they are the methods attached to the thread run
☝️
are you waiting for the packet to be received before moving the player
which player?
i dont know what you are doing
what packet are you sending and receiving? just a number?
i'm sending a status class that has attributes of the player, floats and bools, and the packet has this structure : headerByte + BodyLength + Body
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
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
should always expect a delay
60 fps is 16.7ms second, i dont believe the ping itself is under 30ms
on localhost???
well not local host no
lol
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
that's why i'm ignoring the previous packet, and sending the next right away when the status change
packets are not received in order in udp too
unless u mark them
like if you receive packet 48 then 46 you ignore 46
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
is something not showing properly in the game?
ehm no, cause i just have the characters, everything plays fine for now, but the character moves not smooth like the playable one.
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
@grim violet uh ok,
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);
@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
isn't that the best approach for a 2D game? :/
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
i tried to pass the axis force values instead, but it isn't precise at some point...
or it wont move smoothly
Ok Devil, but more i asking how for this man can work it
sorry for my english can be rly bad
isn't lerping using the force values instead and moving the character with the same controller?
shit
it WORKS!
black magic
Kio use photon tutorial and example
demo example that come with that probably have it implemented somewhere so you can look at it
@grim violet isn't lerping using the force values instead?
sorry, the Input 's force axis
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
yeah it's basically the value of Input manager X and Y axis
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
what happens if i use the same AddForce with the input values?
i mean, for now it seems to work
why?