I would start though if you are looking into learning how to sync transforms well with a 2-4 player thing
Haha, this is what I'm still doing 9 years later. Every beginner including me wanted an MMO, but experienced game designer/programmer realize that MMOs are simply not fun to play, neither to develop.
Massive amount of players in close proximity does not guarantee that the game will be fun to play, it's quite the opposite - it brings serious game design challenges.
#archived-networking
1 messages ยท Page 74 of 1
I imagine it's primarily about production issues than design issues.
I avoid static unless its like player configs for the local player. Say every player has an inventory, is it ok to use static variable for the current selected item for the local player's inventory (the one belonging to the client) or should i just avoid that and use events? Im currently doing events but need a second opinion.
probably a dumb question, ill just stick to events..
Guys can anyone help me regarding an infinite loop problem? Basically i have a do while loop that keeps checking for a static variable in another class, and when the variable is set to false, the loop should exit, and the scene shoul load...but it doesn't...i mean, at some point the loop stop checking for the variable, and even the Debug.Log() doesn't show, so i think there is an infinite loop somewhere...This is the class that has the do while loop https://hatebin.com/mqseduqejt and this is the class that has the static variables that the loops keep checking https://hatebin.com/tvqeaozthz Can anyone tell me what i'm doing wrong? ...even if i do return in the second class, the program keeps checking for messages. Only if i disconnect one client, and the other one receive DISCONNECTED, the loop exit...is so strange....
Guys, can somebody say what exactly is this error
SpawnObject for RedPlayer Variant(Clone) (UnityEngine.GameObject), NetworkServer is not active. Cannot spawn objects without an active server.This error pop up whil I conect to server from unity as a client
This is the code
public class TeamSetup : NetworkBehaviour
{
[SerializeField]
private GameObject RedPlayer;
GameObject PlayerPanel;
public Transform[] PlayerPositions;
//public Transform[] GreenPlayerPositions;
//public Transform[] BluePlayerPositions;
//public Transform[] YellowPlayerPositions;
void Awake()
{
PlayerPanel = GameObject.Find("PlayablePanel");
}
[Command]
private void CmdPlayerAddition()
{
SpawnPlayers();
RpcPlayerAddition();
}
[ClientRpc]
private void RpcPlayerAddition()
{
Debug.Log("Client RPC Executing");
SpawnPlayers();
}
private void SpawnPlayers()
{
for (int i = 0; i < PlayerPositions.Length; i++)
{
GameObject player = Instantiate(RedPlayer);
player.transform.SetParent(PlayerPanel.transform);
player.transform.position = PlayerPositions[i].position;
player.transform.localScale = (player.transform.localScale) * 0.2f;
NetworkServer.Spawn(player, connectionToClient);
}
}
public override void OnStartLocalPlayer()
{
base.OnStartLocalPlayer();
CmdPlayerAddition();
}
}
Guys, can somebody help me please?
You really should ask on mirror discord
Here you have people who doesnt even know what mirror is
another question, any have if Websockets for a MMO is a viable option?
i think is a bad idea for bandwitch
Bad idea: mmo
Several developers already told you that, believe then
Them
Start with something very small, that's all there's to it
Anything you ask about mmo people will just laugh inside, that's the truth
thanks for the advice but all people do the same. I know others devs have try to create a MMO, but maybe other people who ask about this questios meaby have experience with developing videogames creating offlines games and now they try to create / investigate about MMO or backend structure.
And all answers are ... bad idea but don't answer to the question.
Why i'm going to ask another question if the answer is going to be the same?
maybe the first question is , have you experiencie? because i know if u don't have experience if a bad idea create a MMO but damn people who have experience in offline videogames, why try to ask to another devs if the anser is going to be the same?
I do
I do have experience with online (and I know how to create MMOs)
And the answer is: don't do it
Let me try to rephrase it...
If you are into home-improvement... You like to paint, to do some rebuilds, maybe some furniture... Very DIY guy, right?
Then you come to an engineer and ask this question:
- Hey, how do I build a skyscraper by myself?
@orchid cairn for some reason that isnt working for me
That's what you are asking
Does it even make sense to ask this question (how to build a skyscraper)? No, it does not...
That's what everyone is trying to tell you...
@versed rock
It's not that simple, not nearly that simple
yeah but the question is different, the question is not how to build a skyscraper, is "can i use paper to create a skyscraper?"
i simple, create MMO with WEbsocket? right or bad idea?
Bad idea for bandwitch, maybe depends of the type of project
but if the first anser is
Yes, but that is still misleading, because paper is 1 out of 473 thousand other things
No, bad idea create a MMO
You have no idea what you are taking about
is like, ok, so if everytime i have question i have no, why question?
An MMO has SEVERAL connections, to several servers (multiple backends, for different features, multiple gameplay servers)
May you use http for some rest operations, yes...
may you use TCP, yes
may you use UDP, yes
You'll probably need all of them in some fashion
Will you build an MMO using ONLY websockets? Probably NO
Notice I'm taking my time to answer, although you'll probably not understand
yeah, but this is a better answer than no, bad idea.
Now i thinks Websocket are bad idea for bandwitch and maybe another things
The CORRECT answer is REALLY: do not try to do an MMO, try something else...
You'll have more fun and more success and learn more
10 years later you think again about mmo
Now i thinks Websocket are bad idea for bandwitch and maybe another things
It's not because of that
and other things
It's just, don't...:)
You are asking if using paper is good for building a skyscraper, and concluding NO, it is not because paper does not resist traction
The correct answer is:
- paper IS used to build skyscrapers
- in the blueprints
- in the drywalls
Among several other materials
You are asking if using paper is good for building a skyscraper, and concluding NO, it is not because paper does not resist traction
@gleaming prawn this is the type of answer i think, and yeah ofc you can add the idea of .... maybe is no the best idea for start if you don't have experience
I think it helps more than a no, bad idea
bad idea create a MMO
That's still the correct answer: do not do it
๐
Most people don't even answer, just laugh (that's the truth)
I'm one such person who would have laughed. But I'm not sure if that violates the rules of this discord.
but nevermind whether or not you have the technical know-how to make it. Can you afford to host one?
Should we assume you want to make an MMO and sell or is it a learning exercise?
and the ones who dont laugh are crying as their dreams die
Hi, im currently working a on a net lib that will only be used within a local wifi. Im currenlty using TCP but i have concerns that this would slow down sending/receiving. I would change to udp but scared of adding a reliable layer on top of udp(since i dont know how and also im limited with time). What would you guys do or do you have any suggestions ?
validate your concerns with experimentation ๐
on local wi-fi you probably wont have much lag or packet loss
Is it impossible to handle Oauth with unity?
On LAN a TCP lib would be fine...
Hello, I'm new in photon,
I have a problem, but before Iโll explain a little bit what my game looks like : it's a 2d game where there is a single player mode where you can farm rarer weapons than others have armor, improve hit points, have passive or active artifacts ... A kind of solo "rpg"
So this is my problem now, I have instigated a "pvp" system in 1v1, for the moment the room system works but the problem is that I would like our characters with all their characteristics to be instantiated with the opposing player, (he doesnโt there will be no movement, it's just a question of look) the problem is when we do a prefab in the resources folder we can not have all the mesh of the solo mode, the 2 players are identical with the basic skin and equivalent characteristics. So I would like to find a way to instantiate your own character without passing the prefabs in the resources folder!
I inquired and saw things like" viewID" or "RPC" but it did not work for me, or simply I did it wrong maybe?
Any help would be welcome !!!
Thank you for your help,
Cordially.
You need to come up with a way to summarize the look of the character. Photon allows you to send Hashtables, object[] and more but preferrably, the look is a lean byte[]. Then you can send it.
If this doesn't change a lot (or at all) you can set it as Player Custom Property.
https://doc.photonengine.com/en-us/pun/current/gameplay/synchronization-and-state#custom_properties
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!
oh okay, will that be seen by all players?
Okay, I'll try this right away!
Thank you very much !!
Hello there, i wanted to ask if someone could give me a hand on a ai asset i got, the ai works great and it attacks the player, but now i want to make it run through multiplayer, but the issue is that i need to drag and drop only 1 player to ai script so that it can work, the ai ignores the other player
Im not really familiar with ai in multiplayer
I thought maybe ifi could make it with tags, soo the ai only attack the game objects that have the tap (player)
What asset?
@fading pawn all in one character controller
link?
Can anyone tell which programming language is used in Unity??
c#
Thanks
guys i am working on a lobby for my game server, and i was messing around about getting current server status and some HandShaking info from the server, but without actually connecting to it, i was thinking on adding rest API and retrieve the info using http, you guys think its a good idea?
i think opening a tcp for real time communication is over kill for this ๐
also i don't want my actual tcp connections to be affected by some one not actually playing on the server
@fading pawn https://assetstore.unity.com/packages/templates/systems/all-in-one-game-kit-elc-character-system-55598
Do you know if Photon automatically switch the master if it leaves the room?
I think so
so i decided to give a go with HttpListener in async mode, let's see how this goes.
so dots netcode pushed another year ?
i am using my own netcode
these frameworks they make have too much overhead, i like to be able to optimize and fine tune my code ๐
crush those milliseconds ๐
so the rest API worked perfectly
i think i made the right call
it runs in a separate thread, beautifully
my server don't even notice it happened ๐
@cedar cloak yes, a new client becomes the master.
Honestly I'd use something else than Unity to crush milliseconds. This engine is more likely fitting the "just get things done" role.
Rapid prototyping, exploring new mechanics, preparing demo for a publisher, learning how to code, getting a contract job done - that's a bliss. But that's all there is to it.
Anyone have advice on measuring netcode performance?
@graceful zephyr Where are you seeing DOTS NetCode pushed another year?
Q2 2021 a post today said for official production ready.
@mental hull all of their public marketing material have been changed to Q2 2021 for netcode
it used to be Q2 2020
uff
Any word on the other important components like Animation, etc?
holy crap
this is exactly the place I was looking for
an entire channel dedicated to networking in Unity
Wait until next year, so they postpone again
They've tried 3x already... why not a 4th?
wait what
also what happened to unity 202
*2020
is it just not coming out this year?
its almost halfway through 2020
each subsequent year the unity version for the year gets released further and further back
meanwhile ue5 ๐
jk
im looking for an oauth solution. i dont think its possible to get access token response as it is sent to a redirect url. im using twitch as a login
@stray scroll Did any1 expect anything else?
Not that it was pushed, but maybe that they at least would do it with some update and reasoning behind it
@latent hawk, you left Programmer.
hello, I would like to create a store between players, a bit like on "fifa", that is to say; for example, a player puts a weapon of his inventory on the market, he fixes the price, all the other players can see the weapon and if they buy it the money of the buyer returns to the seller.
In addition I would like that as long as the weapon (or other) is not bought, they remain on the market for an indefinite period.
Thank you for your help.
Cordially.
Im trying to make a combat system in unity but when ever the player kills another player it kills every player with the kill player script on, how would I fix this?
here is the main part of my code
You're telling all players to kill their playerObject? ๐ค Then you'll have to expect all playerObjects to die?
Yeah that's the issue I'm not sure how I would make it just kill the player the player is attacking
every frame too lol
the problem is that the health value is static so every time you reduce it, it's reduced for every player. So everyone with KillPlayer script has the same hp value and dies at the same time
but how would I fix this?
You can store a key => value pair in an array
where key is playerid and value health
uhhh .. remove static ?!?
LOL
how to turn a static into an instance as a question indicates you REALLY should not be trying networking yet. Networking is probably the hardest part of game dev, you want a firm grasp of C# and Unity before even thinking about it.
Cheers Varant
Typically people just make a health component, that is tied to the Player component.
Assuming things other than players can have health.
Otherwise people often just write the health right into the player component. Though not really a great practice.
It's a bit hard to tell on mobile, is this channel specifically aimed at Unity-specific networking solutions or are custom solutions for Unity also fair game? :)
Found it ๐
it used to be Q2 2020
and expect this new 2021 date to be postponed in a year and you will not be dissappointed
anything this far off that involves DOTS is high risk
high gain
All in ๐ค
i wish there was more talk about sockets in here
It's not the socket that matters, it's how you use it.
coderx probably was traumatized by this chat and left us. I feel ya bro.
@weak plinth Game genre and unity skill level and budget?
@sonic marsh Action-Adventure Game and unity skill i would say beginner but about to be Average and budget 000000000
then use Mirror
thanks
all good
@sonic marsh worst case wdym?
all players in the same spot, so all data has to be sent to everyone
oh ok
@sonic marsh Im making a 2d rpg game and is it ok if it had a generator for maps
auto i mean
its an open worldd
thats all on you, you will need to make it and make sure it syncs
oh ok
hello
i have a question if i set up my mirror and its working and i release it on steam would it work?
@sonic marsh
or does steam
have its own network
dude thats like 1000 questions underneath
yes
but theres TONS for you to do
dont even worry
like get it working
then get your friends to try it on lan
then get it to work over internet
ect
ill try lan first
steam is like the last step
๐
@sonic marsh last question does mirror have register/login system or do i have to make my own and connect it to mirror or is it different?
not sure on that
probably make your own
again i would say that should be very low on the priority list
or on steam you just have to get a username?
prolly the best way is upload it on steam and just give it register username thingy
and steam is the account
xD
oh yea your right
but
they will have the same name
because its steam
@sonic marsh
and people dont want that
they want their own cool names i guessw
xD
So, im using an esp8266 arduino to multicast UDP packets on an ip on port 80 where its hosting a wifi server, and i was wondering how I could make unity recieve the string of data being sent over the network. Ive tried different sources, like https://answers.unity.com/questions/1406338/send-string-from-one-client-to-another-using-udp.html seems to be deprecated, and https://forum.unity.com/threads/simple-udp-implementation-send-read-via-mono-c.15900/ returns me nothing. Although the problem may be with my arduino script, which I can attatch if requested. Any information is helpfull, thanks! ๐ (@ me if u can respond)
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
@weak plinth No real ideas, but maybe dont use Port 80?
Oh and maybe look at wireshark (or whatever is the current tool) and see if you can see any packets flying round
why dont use port 80?
port 80 is mainly used by web servers to serve web pages
its probably nothing, but just in case something else is claiming it or theres some special network rules floating around
guys I have a question is it possible for the server or network to auto generate the map so that the players wouldn't generate the maps? and also delete the used map and regenerate an another map again?
@sonic marsh
@weak plinth yes but no, you would most likely have to use procedural generation, and if youโre hosting the network on say, a chip, then it might be a bit much for the processor to handle, if not, itโs most likely probable but it will take some time for the map to generate depending on what noise you use. Thereโs perlin noise, simplex noise, coherent noise, etc.
@weak plinth yes but no xD
๐
@weak plinth Mirror is a networking library not a host
i highly recommend not worrying about hosting or servers or any of that, instead focus on using mirror in p2p mode, No dedicated servers (a player is your "host") and lan play only
that will be a MASSIVE effort
Procedural generation is like what Minecraft used to make its map. Itโs essentially random noise that can be used to create highs and lows on a map naturally
so like a seed in mc?
Exactly
@weak plinth Network game programming is probably one of the HARDEST forms of coding
I reccomend using the accidental noise library port for unity
hmm thanks for teaching me cuz im dumb
what language
?
Hereโs the library
Either one would work, but this one I think will generate the best results. Thereโs a few example pics I can show you.
is this 2d?
show me pls
That was created with the accidental noise library
can i create tiles with it?
or no
Absolutely, itโs just take a bit of work. I made a 2D example game with it using a tile map. I can give you the project later if youโd like.
yea id like to
very much appreciated
And if youโre doing a 3D game you can do that too. I spent a lot of time on the subject bc I wanted to create a terraria clone lol
xD
isnt terraria 2d
Yeah, but you can still make 3D games with the library.
Hereโs a tutorial sort of explaining noise. Itโs written in lua, but is still informational
Accidental Noise Library
well thanks but my pc cant handle 3d xd
(Honestly neither can mine lol)
@weak plinth Very nice, will bookmark that and read later
I figured i would just use lib noise for my procedural gen, nice to see what else is around
Yeah, a lot of cool but under appreciated libraries out there. Lib noise is fun too though
@sonic marsh what language does netwoking game programming use?
@weak plinth What you should start with is either the main gameplay in a blank/simple map and get that working or networked OR start on the procedural gen and have it work off a seed (like minecraft)
@weak plinth ??? your using Unity right?
yea
then c#
ok
@weak plinth have you made any unity games/demos/prototypes?
well nope not yet but im confident in my ability to work on my fricking big project
๐ yea i get that
i would highly recommend doing a little proof of concept first, single player just to learn the basic's
and i dont even know how to make music for my games
@sonic marsh I already know the basics i worked on some demos
๐ networking would count as massive by it's self
yup
everyday 12 hours on my game Xd
wow jealous ๐ i have to work so i only get like 3
Thankfully thereโs a lot of good networking tutorials though
yea its everywhere ๐
any of the UNet ones will work
oh ok
Mirror is just UNet but wayyy better
Yeah Isnโt unet deprecated?
plus they probs have tons of their own now
yea but Mirror is basicly a open source version of it
yea it is
they decided to stick to all the same ideas
oh
but fixed all the issues
so basically the same as unet
๐
what?
so do i need to learn unet
yea its basically the same as mirror
but why not mirror?
use a mirror tutorial if you find one
i just dont know any
they probably have some on their site
but unitys offical UNet ones will apply to mirror
hmm ok thx
Ahh @weak plinth I finally found the one tutorial that helped me itโs here https://youtu.be/UK57qdq_lak
In this video we set up our Player and begin moving him around.
โ Download cool Weapons: http://devassets.com/assets/modern-weapons/
โ Developer Forum: http://forum.brackeys.com/
โ Download project (GitHub): http://bit.ly/1JOvQ61
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท...
@weak plinth thanks sorry for late response working on my project
You can do that in the RoomOptions parameter when you create a room.
It's RoomOptions.CleanupCacheOnLeave = false in that case.
Alternatively, if only a few objects should persist, you can also use InstantiateSceneObject() on the master client (not everyone can do this, due to concurrency problems).
@stiff ridge 'RoomOptions.CleanupCacheOnLeave' was creating some bug for me a month ago so I had to set it to true. Can't remember what bug was it.
Will using InstantiateSceneObject(), keep all player game objects in room if any one of the client leaves for the remaining clients?
still desperately searching for a solution to 2 step oauth in unity
isnt possible with web request
was creating some bug for me a month ago so I had to set it to true. Can't remember what bug was it.
you can try it again.
overall, PUN is not extremely good at passing networked objects back to the owner, should this player come back. in the mean time, the object may have moved and this is not synced yet.
we happen to work on this these days but it's complicated to get right and generic.
what's your use case @drifting ridge ? PM me, please.
@stiff ridge , ok found the bug: https://forum.unity.com/threads/weird-errors.874366/
Setting it to false solves that bug.
But I found a workaround. When the match ends, I remove all photon view components from the game objects. This prevents it from vanishing when the other client leaves.
The pic is the results ui display which is in the same scene as the gameplay. I simply move their position to a showcase position. Are there any negative implications on doing this workaround?
Hi I have an issue were a player gets destroyed on the local clients screen who has destroyed the player but the local client that is suppose to be destroyed still exists
Here is my code
Hey all, new here.
Just wondering if writing a custom udp server /client is the right approach for multiplayer; do I have to use Mirror (or other services) if I know networking already?
"for multiplayer" is too broad. It really depends on how clients/server interact and who has authority
public override void OnPlayerEnteredRoom(Player newPlayer)
{
base.OnPlayerEnteredRoom(newPlayer);
Debug.Log("SOMEBODY JOINED");
Debug.Log(newPlayer.NickName + "JOINED");
}
I made this simple script to notify the players when and who another player enter in it
problem is that "newPlayer.NickName" its empty
did you set it on the other client?
wym?
this script is in every client
should I first assign that newPlayer.NickName its string nickname contained in another string?
Documentation states that Player.NickName is only updated when it is set. Did newPlayer's client set NickName before entering the room?
wait how can I update it before even entering the room? to you mean that I have to communicate it to Photon servers?
if you dont know how to do that why are you expecting it to have a value?
perhaps what you're looking for is userId
is there a better way to do 2 step 0auth with unity than embedding a browser ?
if you dont know how to do that why are you expecting it to have a value?
@slim ridge should I do something likePhotonNetwork.NickName = Launcher.myProfile.username; (aka my username string)right?
@stray scroll I'm unsure what I should be looking at on this thread
@nocturne osprey what are you trying to use, there's no such thing as 2 step 0auth
question about Photon
Free version can only support 20CCU
doest it mean 20ccu globally per server or in rooms?
for ex. can I have 1 room of 20 players and other X ones waiting in the Menu?
@amber trench there is 2 steps for a user to auth so that you can get their access token. i can't find a way to get the token from the redirect after the second screen as this action is taken in their browser
webrequests cant complete the process
figured it out cheers Jaws
@nocturne osprey If configured correctly, it will redirect to the redirect URL you specified with the OAuth token
From that screenshot, it looks like you're redirecting to google.com instead of your own app domain or loopback url
sorry, the redirect on that image is taken from another game that has it working. it only redirects to a URL but my problem is that I want it to redirect to UNITY
How are you performing the request?
i dont have a solution at the moment. i want to allow users to login using their twitch login
i cant use webrequests because of the redirect issue
only solution i can think of is embedding a browser which i dont really want to do
Web requests can be configured to follow redirects
But I guess it's not an immediate redirect, it only happens after the authorization
Let me check on something
yup thats exactly the problem. all the stuff on twich api documentation using curl etc is done when the access token is already known
Have you considered, as a temporary solution at least, to run a web server that holds the endpoint that gets redirected to?
yeah but that doesnt solve the problem unless i have another login system in the game too (making twitch login redundant) otherwise there would be no way to safely link the game to the webserver
So you are looking to use Twitch for authentication in your game
yeah
I don't understand how that would be an issue though.
User goes to 'login'
Web server spins up with the endpoint that will get redirected to
They authenticate
Page redirects to your local endpoint
Unity can see that they authenticated and hold the token somewhere safe
what do you mean by "Page redirects to your local endpoint"
cos unless its something within unity itself then there wont be a link between the game client and the web server
for oauth, you need a web server to receive the request from twitch
right but if on the server its at example.com/endpoint if i want to read that page with webrequests i can only query that url but theres no way to determine if its retrieving the collect access token (assuming multiple users)
ideally i would be using web requests but thats not possible because there is 2 parts of the auth process. second option would be redirect from twitch to my game which also seems not possible. that leaves requiring more input (bascially another login system) to compliment the twitch input or embedding a browser
i was hoping that i was missing something with oauth that would make things easier
the oauth process works something like this:
user enters credentials
twitch confirms credentials
twitch redirects to the url you specified with the token in the post body or url
your application examines the redirect to obtain the token
it's usually possible to examine the redirect
(non-embedded) browsers wont have access to the redirect
is your app a mobile app or desktop?
desktop
I'd try to embed a browser then, and if that's not possible then create an application protocol and a small webserver to redirect to it
but i'd think twitch would have some library for unity that makes it easy
hmm ill look into it some more. thanks for responding!
Is there anyone with good knowledge of C# and TCP networking that can help me perfectionate the network class for my game? ๐
I'd really appreciate it, you will save my life from going crazy...
i wouldnt call myself an expert but i've built one
Hello, I would be glad if someone can help me https://forum.unity.com/threads/multiplayer-movement-lerp.895388/
the problem is your BufferSize but you didnt post any code about how you calculate that value.
ok.
perhaps it's growing indefinitely because you're falling behind indefinitely. There's nothing here to help you catch up to the server if it got ahead.
Yes but I shouldn't need to catch up because I do exactly one lerp per update received
could also be the fact that PositionLerpProgress is only updated when the buffer is full (BufferSize)
that makes sense actually. Every time PositionsBuffer.Count is < BufferSize a frame is basically delayed
yes but normaly the buffer is empty only at the beginning when im waiting at least 2 updates
But I need to wait for my mate to test it because I can't test it locally
I'm working on something similar right now. I'm using a sequence value to keep client and server in sync. Each Update() I process enough frames to stay in sync or interpolate if i'm between frames.
What is a sequence value ?
just a counter that goes up each frame. The server and client agree on what time to start counting and how often to count
If you are doing any testing in the editor, your fps might go below your PlayerPositionUpdateRate and, assuming you queue as fast as you UpdatePositionWithLerp, you wouldnt catch up.
It doesn't change anything because the send rate and the lerp rate are bound to Time.deltaTime
assuming things stay in time.
I'd Debug.Log PositionLerpProgress and see if it ever gets above 2
@slim ridge I did some testing and it doesn't change anything, here is the new code ```CSharp
private void UpdatePositionWithLerp()
{
//Each frame we move toward the target position, we calculate the PositionLerpProgress based
//on the update rate, we use a buffer so the player don't stop if the packet is delayed on the network
Debug.Log(PositionsBuffer.Count);
//We wait until the buffer is full
if (PositionsBuffer.Count >= BufferSize)
canLerp = true;
if (canLerp)
{
//If we reached our target position go to the next
if (PositionLerpProgress >= 1)
{
PositionLerpProgress = 0f;
StartPosition = transform.position;
TargetPosition = PositionsBuffer.Dequeue().Position;
}
PositionLerpProgress += Time.deltaTime / (1f / PlayerPositionUpdateRate.Value);
transform.position = Vector3.Lerp(StartPosition, TargetPosition, PositionLerpProgress);
}
}
The stranger thing is the behaviour is different if we use OpenGL or DX11 xD
at least that confirms my suspicions about framerate
I'd stop tracking lerp progress.
every time you find an item in PositionBuffer regardless i'd teleport to the previous target and begin lerping to the next
i think you also need some code to handle when you arrive at the position before another input comes in.
By "tracking" you mean checking if PositionLerpProgress >= 1 ?
yeah
How can I handle that ? because if I just stop the player it will look odd
that's why I try to use a buffer
I think you mean using extrapolation ?
so your players never stop moving?
Yes but never stop updating even if they don't move
Hi, could you tell me how to solve problem with error: "Failed to find Mirror runtime assembly"
I added new mirror asset from git and started to build solution
during building i have this error
Usually best to ask in the mirror discord, gadget only checks here occasionally. @weak plinth
The Asset Store release is the safer pacakge, and don't use Unity 2019.3.12 - it was a train wreck for a bunch of assets.
lol...โ๏ธ
Im having major issues with UnityWebRequest and I wanna make sure Im not missing anything simple
On my computer, after building and running, web requests to a VPS i own work perfectly. On other computers, certain endpoints on the VPS work while others don't. On these problematic computers, all endpoints work from an http request making program, so I figure the problem is with the code itself. I have gotten the code to produce the error: cannot connect to destination on my laptop but not on my main computer.
I would normally make a forum post, but I tried a few days ago and it's still waiting for moderator approval
Hey guys, does anyone know of any game engine built on top of ECS (or ECS-like design), using fixed-point math, that supports rollback and client-side prediction ?
Pretty much Photon Quantum, but something a team of 2 developers can afford ?
I really don't want to roll my own, but looks like I'm out of options.
@sacred patrol no there isn't any free/cheap option available
because it requires a metric fkton of work to build
there are a few lockstep only options for unity available on github
but they are all pretty subpar and i wouldn't use them for anything 'real', but maybe as something to look at and get started
@graceful zephyr Thanks a lot man. Can I get a link ?
https://github.com/proepkes/UnityLockstep
https://github.com/SnpM/LockstepFramework
https://github.com/mrdav30/LockstepRTSEngine
GitHub
Framework for lockstep RTS, TD, and MOBA games. Contribute to SnpM/LockstepFramework development by creating an account on GitHub.
they are all pretty.. "meh" imho, but well
completely wrong approach in all of them, and i dont think any of them is ecs-style
https://github.com/kangtachan/Lockstep this also but same thing there
@graceful zephyr Btw what's your fixed-point math library of choice ?
my own
I should have known lol
:p
Much to do, much to do...
if you want predict rollback
none of the ones above
can do that (easily)
just building your own physics engine that's good enough for a game
is like a years worth of work
Yeah I figured. Luckily I need just the raycast alone. Something simple like casting a ray onto a straight 2d line.
@sacred patrol if you want im part of a private discord where there's a lot of talk about networking, determinism, etc.
i can invite you if u want
Sure. Thanks.
If I were making a proper game that is going to market and have a budget behind it, I would seriously consider Quantum before rolling your own. The $1000 is less than you would be paying a net dev to build and maintain your own library, and it shortens the game dev time massively. The main issue would just be that your networking will get ahead of your game content. But if you want to build your own as more of a hobby or learning thing, go for it off course.
@jade glacier I know right, I would have definitely used Quantum if I had a publisher. But I decided to try and make things on my own without financial support.
So now all I have is $7000 to buy myself potatoes and pay the bills until the budget runs out. (With some passive income helping along the way)
So currently there is no way to create a multiplayer game in unity? if I don't want to use SpatialOS or Photons - https://blogs.unity3d.com/2018/08/02/evolving-multiplayer-games-beyond-unet/ this is so confusing. What is the official unity networking framework ?
That page is kind of a running joke.
Ok but its still on the official unity blog and its misleading
Photon, Mirror and MLAPI are pretty commonly used. There are people using NetCode, but that requires you to go balls deep into DOTS, which is preview... So unless you are wanting to get into that, best avoid unity's networking for a while.
UNet - no. Mirror - maybe.
The most correct answer is to abstract your simulation entirely from your net library. And it won't matter. But first attempts at making multiplayer are going to be an entangled mess.
So just do demos and quick and dirty experiments before trying anything real.
When you get good at networking, you will find you have reduced your entire game to a tick based simulation that uses buffers of states and inputs, and your networking just becomes the serializing and sending one or both of those buffers to others in the form of a byte[]
Pun, Mirror and MLAPI automate most of that, but also as a result make it hard to avoid entangling your messaging layer with your simulation layer.
So you kind of just have to go make a few messes, so that any of what I said will even have meaning.
@tired raptor that blogpost is a like...
yeah, a running joke in the networking community
they basically made a flow chart to show how much they've fucked up ๐
Fucked up is generous... "up" being a positive direction. ๐
"Up" might sue them for defamation of character.
Netcode is doing a lot right, but its at the end of a long chain of dependences on other parts of the whole DOTS strategy, so you have to dive in completely to use it.
lol yeah I guess I should have figured that, the bar that indicates their progress surpasses 2022
Thanks guys for the clarification ^_^
Q: I am switching from photon host to photon self host, anyone know the amount of ram a dedicated server needs per player? or per 100
@sage saffron Completely depends on your game, and what you're doing on the server
It's simply not possible to say "you need X mb memory per player"
@graceful zephyr or someone. It is 3D fps. 40 player lobbies.
Just trying to get an average. I donโt want to setup a 8gb vps and it gets overloaded and the game shuts down. So if I can calculate how much ram 40-100 take by the amount of active players daily then Iโd know what to host on.
For 3D fps, would want to know if each group of 40 took up 1gb of the vps, or 64gb of the vps.
Do you have any idea how to make a 40 players FPS?
First make sure you can make your game,
Each of my lobbies have 40 players
Have you ever made and released a multiplayer game before?
A 40 player FPS is not so easy to make (a good one at least)
I am using photons host and its plan of pay per player. Would be nice to switch to my own host. Uhh Erick thatโs not helpful
Your question sound like you have no experience with this
Nobody will be able to help you, sorry
I'm just honest
you need to design, build, and test your networking solution before any benchmarking can be done.
Clearly no one knows. My game works fine and is already hosted, but would like to use photon self hosting sdk
1 user could take anywhere from 0 ram to 8 gigs for all we know
does photon have a dashboard for that?
A 40 player FPS in photon cannot work well out of the box unless you wrote a lot of things yourself (I work for photon btw)
If you have, you would not need to ask this question
Yes photon has its own control panel to setup on your own vps
Photon does not expose memory usage of our own hosted clustwrs
If you self host, yes, you can check anything
Thatโs why I canโt check and am asking
Just test
The free self hosted license lets you host up to 100 players
In one machine...
Before I buy a vps just wanting to know. I can test it myself yes, but maybe someone on here happen to have tested it before and would be easy to tell
Photon is costing me $1600/m
Just don't ask players to host these photon servers, this would be against the EULA
It's is costing that much because of?
CCU or because you are overusing bandwidth?
Itโs costing that because I am paying per player
You will still pay per player with self hosted
Just cheaper... But wil have to pay for the server and bandwidth yourself
But itโs cheaper
Will probably cost you more than that in total
Photon has an unlimited player plan
Unless you put the server in some crap VM, which will make the game run really bad
Yes, but that is just for our part
You need to pay for the machine and for the bandwidth in that VM
You should know that data, that we expose.to you (bandwidth)
That will cost you a lot, I guess
Because a 40 player game in the same room (assuming you run stock pun) uses a considerable bandwidth
Photon self host for unlimited CCU is $175/m. If I know what specs I need for a vps I can add it together and see if itโs cheaper than $1600/m
Just try it in a very cheap VM first
Bandwidth is expensive
1600 / per month is a lot of players
You probably have a lot of players...
How many CCU is that?
Iโll just keep paying for photon host itโs nothing. Figured I could get it cheaper
Well
There's a reason why even big companies still use.our clouds instead.of self hosting
Just go ahead...
I'll come back...:)
You will*
Alright Iโll use it. No big deal, figured it would be valuable info to know tho. 5500 players
The most important reasons why some companies self host are:
- some security legal things, like the military
- a special deal to run outside the internet, etc
5.5k
Photon host is easier anyways lol.
You won't be able to host that in a single server
Was just curious if I could switch and how pricing would change
You'll need at least two, setup with master server plus load balancing, etc
Thanks for saying no lol. Iโll stay on photon
I tried the test on photon control panel but the stats were up and down, I couldnโt get an average
I'm just trying to give you the reason why other companies keep hosting in our clusters instead of going self hosting
Btw
Assuming you are using pun
If anyone here knew then it would be nice. Itโs no problem, I can use photon website
PUN2
Memory will NOT be your issue
The photon server process is very streamlined
It will not leak memory or use too much, etc... I'd say it will topically consume some 1GB or 2 at full capacity (again, assuming pun, no shitty data stored on server)
But at 5.5k CCU, you'll need more than one server, I assure you
You should not need 4
You need to read well the docs to setup the servers as a cluster
With the lobby/master running load balancing to distribute rooms between the game servers, etc
Make sure you monitor these, and so on
This is part.of the service we run, if course
Memory will not the a problem, bandwidth will, I think
I can rewrite it to work as a cluster no problem, but I still would need to know what specs. I am fine using photons servers, no issues. Was just a big curiosity on if I could switch
And VMs are much worse than the baremetal machines we use (in terms of network hardware performance)
As I said, machines with 8gb will Probably work, but I do not know what your game does, so this is just an educated guess, absolutely no official answer, etc
You should be the person capable of answering... The bare photon server uses very little ram
Itโs ok, you did your best. Photon pricing does not say how much ram is included.
Because this is not something we can answrt
It depends on your game...:)
As I said, just the server would use somethi fluke, don't know, around ridiculous 40MB or so?
I understand. I like the setup photon has
But your game will push data into the server, this we cannot know
Room properties, player properties caches ops, etc
Hi, I'm having a huge issue with mirror networking, I've been trying to fix it for two days now, I hope u can help me. The problem is that when I spawn the player prefab on a client, for some reason it doesn't have islocalplayer as true.
This has caused two main issues, the first one is very weird, I have an if islocalplayer, print something, and else print something else, but both prints appear in the console, and the second one, is that it won't let me run commands, so I can't to much really, plz help Ive been trying everything the hole day today and yesterday's afternoon and still can't find what is wrong.
The running queues when handling 3k+ connections in one machine (the data for these connection queues are sent by your game)
For mirror, I suggest the mirror discord
Erick, its alright ๐ I understand its hard, just wanted an average for 3d fps. I have no issue with using photons hosting.
We honestly cannot know...:)
A 3d FPS is not enough of a descriptuon
How much data do you push per.client per second?
How much data do you keep as player and room properties in avg
A regular machine, how are these srrvers you get for cheap? 8/16GB?
Anyone?
And CPU wise? You'll need to test... We are not allowed to share what is the specs we use internally... I can just say we run fully on baremetal, except for burst capacity
Iggy, you should ask on mirror's discord
They have a dedicated discord and they are cool
Do u have the link?
No, but it's on their website
Ok thanks
I guess, it's whatever is their official disxord
I know another company who runs self hosted photon @sage saffron
Albion online (mmo). But in that case it's because they do not use the basic load balancing setup + pun
They wrote their own server logic on top of photon server sdk
Im good. I dont have a problem with photons servers, and its not that high of a price. I have lots of curiosities
@oblique elm Mirror's discord is linked on the asset store page
I'm already in, thanks๐
Hi I have question/situation regarding ScriptableObjects and my Host and Client...
Basically on my ScriptableObjects have been changed differently on the Server/Host/Client. Then when my new Client Connects, all of the ScriptableObjects are the same (the unchanged Objects, all just one object). I want the Client SO's to be the same as the Servers, how do I fix this?
patch your clients
or use something other than ScriptableObjects. JSON or protocol buffers can help you there.
@slim ridge use something other than ScriptableObjects!? or you mean use JSON and protocol buffers on top of/as well as/ ScriptableObjects?
someone knows a good tutorial for LAN networking?
Is Unity's DOTS NetCode preview package even worth bothering with right now?
Looks like it hasn't been updated since November.
Ah, just came across this thread saying a new update is coming soon after the next Entities update: https://forum.unity.com/threads/netcode-next-release.885409/#post-5876800
@dusky salmon nope, not even close
@humble socket as far as i know, ScriptableObjects are assets and you can't really change those at runtime. If you changed them you'd have to release a new client build or build in some way for the server to provide this data to clients
@graceful zephyr Alright. Well, I'm feeling both brave and foolhardy today, so despite your warning I'm gonna give it a shot for a side project. May God have mercy on my soul.
I would do tutorials for a few net libs and a junk project or two for MP before even trying to think about making a real MP game.
@jade glacier
i only found difficulty in networking is how to understand the topic and convert it into code
something like Lag Compensation or client side prediction
I can't comment on whether you fully get the it or not without seeing your code or talking about it with you. But typically most first time networking attempts result in message based sync, rather than simulation based syncs. And that typically leads to a painful mess of race conditions.
ok
just remember that the ultimate proper model is:
Messages <-> Tick Based Input and State buffers <-> Simulation
Messaging and simulation should never directly touch one another.
Proper game networking is mostly about making your simulation into something that can be networked. Messaging is just how the states/inputs that get buffered are transferred.
What you want to avoid is things like writing and reading messages directly to your states, or to directly trigger events. That is the path to hell.
has anyone tried using signalr with unity?
How would u go about implementing team selecting because in my game I choose a team and when I choose a team the player is also instantiated so I cant check what team each player is on Im not sure how I could solve this issue besides assigning the teams when the player is already instantiated
@empty quiver Or change the spawning logic to wait until the team is known
Or just modify the player object as needed (color change etc) based on the team value.
If the player object exists while despawned, then just use the same code that hides/limbos the player for pre match.
Can I put a game on steam using Photon base plan (20CCU)?
You can,.. legally it's all fine
But if you get more than 20 at the same time, you need to move up to another plan
if I call an RPC from another script is just the stringame is enough?
For admins: is possible to have special and separate text channel for NetCode?
But how do assign a certain player to a team with out assigning all the players to that team?
Can't really answer that without knowing your player code, but it would just be a state (field) that gets synced for your player class.
Every player has an object (the actual player prefab perhaps) - and those each should have an entity ID (named differently depending on what library you are using)
If your player class has a field
byte team;
That would indicate the team. You would sync that value.
I was starting to learn the Photon code but I noticed that for a published game the prices for host even a little portion of players are a bit too high for an indie. What are the best alterantives that I could considerate?
Depends on the game, but someone is going to want some money if they are running your server code and providing bandwidth. So you mostly have to sort out cloud vs hosting with a metal box vs whatever else based on your game first.
If it needs a Unity instance to serve its going to get spendy.
I wouldn't really recommend trying to do MP as an indie without some funding. All avenues cost money, and you don't want to be making game design choices around short term cheap thinking. Successful MP games are going to need budget, since MP is only good if you have a player base, and player bases cost money to get.
Hi, do you usually use a heartbeat also to determine ping ? Or rather having a heartbeat to determin that the connection is still alive and a ping/pong just for rtt ?
I personally use consumption/apply time for my RTT calculations, assuming you have a full round about path to clock like that.
You need to know where RTT is measured, so you can factor in the various buffers yourself - if you are going for as accurate as possible.
Interpolation adds latency, transport buffers add latency, and frame buffers can add latency.
If you are tick based, you can just piggyback your ping calcs on your ticks. Otherwise... whatever works.
Though if you are tick based, the use of RTT kind of vanishes, since everything is already tick based rather than time based.
So the short answer is - totally depends on what your system is currently.
Anyone here who knows how to deal with photonnetwork? I got a problem considering connecting to others but it could get kinda detailed so I'd prefer DMs
Best to post your question, doubt anyone will PM you without some idea of what they are getting into.
Okay so I'll try to keep this short. Basically I'm working on a First Person Shooter and the multiplayer works via PhotonNetworking. Everything works fine, everything's synched and I was able to playtest with some friends of mine. The next day I made some progess and added a few features but didn't touch the networking at all. Not a single line of RPCs was changed, nothing connected to the Multiplayer System was added. Then I built the whole thing and tried to play with my friends again but it didn't work. I wasn't able to join them, they weren't able to join me. But here comes the fun part I don't understand. They can join eachother and I can also join them but only if I use the Unity Editor or a development build to play. It doesn't work as long as I use the same .exe file they use
Check your regions
Using the latest Pun2?
Dev Region was added so you can force a region for all development builds, that ensures everyone connects to the same continent server.
@fading radish
Dev Region might be in your current version, which would be why development builds were working for you.
Once you build a release, you might all end up in different regions
yep, current Pun2 and I already checked that, we're all playing on eu servers, even if I don't force the game to
You put eu into the FixedRegion field?
Not sure then, sounds like a version issue yeah - if you are all on the same region
Might be more of a @stiff ridge question if its not region related.
i tried both, with and without the fixedRegion setting. We're always connecting to EU
Super weird. Thank you anyway
I mean as long as it's working for everyone else that's fine - I can always use a development build - it's just bothering me that I can't figure out what's causing it ๐
You may have found a bug, so would be good to isolate it.
I will test it again today, once my mates are awake. Maybe it was just some issue on my PC that got fixed by restarting. Yesterday I tested it with multiple different groups and it always worked perfectly for them, so it probably is something local
Might be worth a rebuild of the project or something before getting too far down a rabbithole yeah
So, you need to use the same GameVersion string, pun version and the same region.
After the Editor connected to the Cloud for the first time, the "Dev Region" gets set and is used in all Development builds. You can either build release or master or you can just clear the "dev region" in the PhotonServerSettings (make sure there is only one file of that name).
You could use a fixed region as well. It will override the Dev Region (as it's more specific).
If they got a release build but you are in the Editor, your Editor will still use the Dev Region (again: if set and if you don't use a Fixed Region).
Alternatively, clear the dev region and fixed region values and use the Photon Dashboard (webpage) to set which regions are allowed for "best region" selection. This is the most flexible definition, as you can change it anytime (not in the build).
@stiff ridge thanks alot for taking the time and answering that detailed. Turns out there really was something wrong on my end... I just got to test it again and now everything seems to work..
But I have a ragdoll problem. I activate it whenever a player dies and on his own screen everything is fine (as in he just falls to the ground - like he's supposed to). On everyone elses screen, he starts sliding in a random direction. I tried giving the main collider a high friction value but that's pretty much all I can think of right now. Anyone who has a better idea?
https://gyazo.com/021ef333e7b6fe57ca67b6b38cb6e673
what's the easiest way to have multiplayer where players can start servers from the game and others can join (I'm extremely new to networking)
There are a lot of PUN resources and videos for new devs
@fading radish, I can imagine that your character is still sending updates, even when you turned it into a ragdoll. On remote clients, the position updates will not perfectly align with the ragdoll solution locally and could cause unwanted movement. Incoming updates and local values will collide and "fight". I would not send position/animation updates for a ragdoll. You can send a flag telling everyone remote to set the character to ragdoll and use the local pose.
@stiff ridge that's exactly, what i'm doing. The Player has a ragdoll object attached that gets activated whenever someone dies and the "normal" player object gets deactivated. That (de-)activation is the only thing I send over the network
@light geyser Also Mirror is a good starting choice
@light geyser Do you want to start servers on the user's computer or on your own servers?
Users computer
I know nothing about networking, I'm decent in unity though
@spring crane
na i havnt used mirror in ages now
but was super solid when i used it
i imagine its just gotten better
but they had a very solid docs/tutorial pages setup
Anyone know a good Udemy Tutorial/Course for Advanced/Basic Multiplayer concepts for Unity? I've recently ran into trouble with my project that involves ScriptableObjects and Server/Client States that are not updated properly....
@fading radish , hmm, then I don't know what's up. If you don't sync anything else (neither transform, nor animation), it may be something sneaky. I guess you set the remote player's character to IsKinematic? Maybe this? Or maybe some settings on the colliders? Some component being disabled instead of enabled?
They are two seperate objects. The character as the ragdoll in a T-Pose, and the actual chatacter. The character model + collider gets completely disabled, the ragdoll + colliders get activated. I don't activate any other components manually. Also, If it was a wrong setting concerning the colliders (or anything along those lines) wouldn't the sliding also happen on your own screen? It happens 100% of the time when you kill someone else, but 0% of the time when you see yourself die. It has to be connected to networking :(
Hm. You make it sound as if it could not be related to the networking but then again .. it only happens for remote characters.
Does the ragdoll even have any networking objects on it? Is it parented to some object (that's networked)?
yes, so I have a Player Prefab, that gets instantiated everytime a player joins. That prefab has a few childs - the cameras, the Character standing up, the Character crouching (temporarily until i get to do animations), the ragdoll, a ground detection object and a text field (to display the username). The whole Player object itself is being synched
Hello guys, i have a problem with Turn Base game, so i want to create a max 7 player game (Card game like poker) and the big problem is the switch between players, is hard for me to get the idea of how a turn will work on more than 2 players. I'm using PUN2 to do the networking, can someone help me? Just showing good resource on the solution will help a lot!
Hello everyone , when i try to connect my android via tcp to my pc server it refuses connection and says : System.Net.Sockets.SocketException (0x80004005): Connection refused
it works in localhost
but not in standalone
what address did you specify?
the android would have to be on wifi and use the server's lan address.
if not you'd have to open the right port on your firewall
I did open a port , and theyre on the same wifi , how do i use the lan adress ? @slim ridge
if anyone else knows , feel free to answer too
windows or unix?
the lan address probably starts with 192.168
windows
open a command prompt and type ipconfig
what should i do whit the ip ?
use the 192.168 version as the target for tcp connection
okay , i will see if it works
Doesn't work...
still same error
I've found out that the error occurs at socket.EndConnect(syncResult);
What range of ports are good for a networked unity game to use?
There is a way to convert a JSON file to Vector3?
@brazen echo Have you tried using JSON.NET?
Does anyone know of any good Unity2D Networking tutorials? Trying to make my 2d mmorpg multiplayer
@pseudo quiver i think its your firewall doing a good job. Tried turning it off?
@jaunty ocean that's an interesting question, I'd also be curious if anyone here has a lot of experience on the topic. I tend to just pick ports I've already forwarded from popular games (6112 for warcraft 3)
There is a way to convert a
JSONfile toVector3?
@brazen echo Not directly with Unity's builtin json converter
But if you have something like:
public class Position
{
public Vector3 value;
}
You can convert the Position class
Tnks
Using this for like initial position on instantiation I hope? And not for streaming position updates? @brazen echo
anyone here ever tried VRTK with PUN2?
Using this for like initial position on instantiation I hope? And not for streaming position updates? @brazen echo
@jade glacier I'm using to update the position in my server, but my function to convert JSON to vector 3 is not working properly
I'm using PUN2 Photon, and I'm trying to use a Photon Transform View to network position and rotation easily.
I've used Photon Transform view before on my player and enemies in another project, so I'm familiar with it's workings. This time however, for some reason, Rotation is being correctly transmitted, but NOT position: I want position networked, but it is not affecting the position of the enemy for some reason...? There are no errors either.
Any ideas why this may be? Why would rotation work fine, but position silently not work?
@vale timber Does the EnemyBody's parent, SpectralRay, have a Photon Transform View as well? I encountered issues when a parent and a child both had Photon Transform Views that governed the child's position. In my case, I had to turn off the Position check box in the child's Photon Transform View.
@jade glacier I'm using to update the position in my server, but my function to convert JSON to vector 3 is not working properly
@brazen echo I resolved my problem and now it works properly
What would be the easiest way to implement multiplayer?
Update: I simplified my enemy design (No multi-layer rig/body any more, the body + photon view is the top layer now). This should make it simpler and rule out the layering issues @marsh bison !
However, I have the same problem: Rotation is networked, but not position...? Does anyone have any possible idea why my enemy's position is not being updated? ^^'
--
(PS: @bitter forge Use Photon Engine, it's all around the best and easiest one that works well!)
got it
Photon PUN 2 specifically*
@bitter forge Use a MySQL database if you want power, or PlayFab if you want ease of use!
Glad to help! ^^
Iโm sorry, @vale timber. I donโt have another idea to help you. (I am very new to this.) I came to this discord due to a problem of my own. I have an OnTriggerEnter2D that I want to activate immediately when a bullet hits the player, but after hitting the player, the bullet continues for a significant distance before registering a hit. This problem does not occur if there is only one player present, nor does it occur if I go frame-by-frame. How do I get the OnTriggerEnter2D to activate at the correct time?
Hey guys. I'm looking to develop a real time online game. I was thinking of making a custom authoritative server for the game. The plan is for the server and the game to run code simultaneously via my own physics library. Will this library have to be c++ or is it possible to have the server run c# code since it's easier to write in Unity?
Its possible to run your server in c#
@rustic oracle would I need to use mono? I guess the down sides would be garbage collections? Any recommendations on c# server integrations?
I'm guessing this is the solution
https://stackoverflow.com/questions/4844581/how-do-i-make-a-udp-server-in-c
you dont have to use mono
i'm writing my server in go, but i dont rly need a physics lib
I have an OnTriggerEnter2D that I want to activate immediately when a bullet hits the player, but after hitting the player, the bullet continues for a significant distance before registering a hit. This problem does not occur if there is only one player present, nor does it occur if I go frame-by-frame. How do I get the OnTriggerEnter2D to activate at the correct time?
decrease physics timestep, use raycast
@slim ridge I'm sorry, how do I "decrease physics timestep", and how would raycasts help? Should I lower the "Fixed Timestep" in Project Settings -> Time from .02 to .01?
yeah, lower the fixed timestep is what i meant, it will cost more cpu but trigger will be detected better. the faster objects move the less effective colliders become and more effective raycasts become
with a raycast you can basically "look ahead" of the bullet for incoming collision
so instead of moving most of the way through a collider before triggering you can calculate the exact time it would hit
@slim ridge I changed the Fixed Timestep from .02 to .001 and noticed no difference. Could you please recommend some resources about raycasting to improve collision detection in a way that works with Photon 2?
im not sure how it would work with photon ๐ฆ maybe the photon guys in here can help ๐
@slim ridge The OnTriggerEnter2D should work to detect collisions, but there is some sort of problem that arises from the networking aspect. Thanks for your help. Perhaps I should use raycasts anyways even though it would not fix this problem.
Does anyone else have an idea why OnTriggerEnter2D would not work with Photon 2?
Trigger is not guaranteed to be triggered if your object is moving too fast
You should never rely on it for this kind thing
Had better use raycast or manual math calculation
@hollow nymph It always gets triggered, but it triggers later than it should. Would raycasts still help?
@marsh bison Do you need to use triggers here?
@spring crane Is there a better way to handle when the bullets hit the players?
Yea I generally use Raycast/RaycastAll from previous position to current position
@spring crane Would that fix the problem of the bullets going past the players before registering a hit? I would think that raycasts would only help if my problem was that the bullets were going through the player, never registering a hit.
Depends how severe penetration is and what problem you are exactly trying to solve
Cast won't hit anything if the position isn't inside of the collider already
@spring crane I posted a video of my problem above.
Are you destroying it over the network?
@spring crane Yes, but it is not destroying bullets that is the problem. The health decrease happens at the same time as the bullet disappears, long after the bullet first touches the player.
[PunRPC]
void networkBulletDestroy(int i)
{
if(PV.IsMine){
//print("Index : " + i + ", existingBulletList.Count : " + existingBulletList.Count);
GameObject x = existingBulletList[i];
existingBulletList.RemoveAt(i);
PhotonNetwork.Destroy(x);
}
}
hello, it's me, again.. Soo my next problem is that the player movement is super laggy, no matter what. The amount of players doesn't matter, the connection speed doesnt matter - after networking, the player always "shakes" a bit, even when standing still but it's obviously worse when he's moving. Here's a gif of what I mean https://gyazo.com/ef4d80c96b8897c84025b138cedc8206
Whatever you are doing for networking, its terribly wrong @fading radish
Guys I heard it's better to have your game server running multiple processes so that if one crashes the rest remain functional, and have a main process which monitors them all and reboots them if they crash.
Thing is, how would the processes communicate and share data between eachother to keep all players in sync? And how would they all run on the same port?
I'm just speaking out of curiosity btw, not working on any project involving this at the moment.
Please ping me if you have an answer.
Depends on the game, but often you can logically separate processes by matches
Communication can be done through networking layer, especially since the watching process could be on a separate machine, and the server processes grouped on separate machines
@fading radish you must have 2 things modify the transform, your networking logic is incorrect
Like you have the server sending the player update position, then locally, the client run the physics simulation, then they are both modifying the position
If you are using Photon or Mirror(the preferred one), you can just use the built in sync transform, both are good
Hello anyone knows how to make multiplayer
Like the tutorials on youtube are so bad, Iโm working on that same MicroFPS game (provided by unity), tryna make it better, but i wanna add multiplayer? Any suggestions. I wanna make it cool, like if a person has the room ID and PASSWORD, only then he can join.
@hollow nymph I just got myself into unity like 5 days ago, so I would need some more help ๐ I can't seem to figure out what could cause the problem you described. Currently I have a player prefab, that gets instantiated whenever you join the game. On there I have two Photon Views - one for the Photon Transform View (is that what you meant?) and one for the player script to sync stuff like the current weapon. Even if I remove the Player Script from the Views, the "stuttering" still happens, so I'm a bit out of ideas. It also happens in the air, so it's probably no collider issue, considering there's only one collider active at any given time, besides the rigidbody there's no physics involved.. I am confusion
I don't think you should have multiple views on the same object ๐ค
@fading radish did that happen on both the server and the clients? the stutter
yes. Sometimes it's worse and sometimes it's not as bad but it always happens for everyone
it's strange if it happens on host (Master Client), because host does not need to use network to sync himself under the hood
so if you host (server) is stuttering, I think it can't be networked problem.
But if that was the case, wouldn't it also happen with your own player on your own screen? If I turn the first person camera into a third person one, it's only the other player that's stuttering
so you are fine locally?
your own local player is good, but you see other stuttering
That's what was happening two minutes ago, yes... Now I reset the Photon View and just added the Scripts again. Suddenly I can't reproduce the stuttering anymore.
nevermind, it's back, but now it's like you said, the host doesn't have stuttering, the client does
if the client is not moving, the host shouldn't see him stuttering, right?
The stuttering also occurs when the other player isn't moving at all. I just realized, that the transform is constantly changing, even without any input. If I freeze the position in the rigidbody and then unfreeze it, the stuttering stops until the player dies/respawns
good, then it's not network problem
it's unity problem
something in your code is wrong
you have to find out who is modifying your transform.position, do you set your rigidbody as kinematic?
no, it's not kinematic
you have to set it as kinematic
if you want to control the position by yourself
or set transform.position
otherwise, it will be simulate by the physics engine and the transform.position will be updated by the physics engine inside Unity
But I control the player by creating a vector depending on the inputs, multiplying it by the speed and applying it as velocity to the rigidbody. That won't work if I set it as kinematic, right?
but does your floor also has collider/ rigidbody which will collide with your player?
I think the problem is , you should not use isKinematic = false, to design your controller. because under Unity's physics simulation, a lot of things will happen (coliision) + gravity , and your character can't be controlled properly by the input
there's gravity problem too
there's built in character controller just called "Character Controller" component
it might be better to use that
or you have to design yours by modifying transform.pos by yourself based on input
Yes the floor is a simple plane with a box collider (rather than a mesh collider since players used to fall through the ground if they fell too fast)
alright, I was afraid that this could take some time to fix ๐ I will take a look at the character controller and if I'm able to implement it without destroying all the other code I have. Thanks for the help ๐
if u just started with unity
dont start with multiplayer
should be obvious
multiplayer is probably one of the hardest things to get right
good tip, but no worries. I've done some general coding before, and this project is just a getting my feet wet thing. I knew from the beginning that this would be way more than one should start with, but I just wanted to do a bit of everything to see what I like and what I don't like doing. So far - besides the stuttering - things are working out pretty fine and I'm not yet demotivated ๐
What are your opinions on Mirror vs Pun2
https://assetstore.unity.com/packages/tools/network/mirror-129321
I mean in terms of ease of use
I'm currently creating my own simple server for my 2D game and I'm working on spawning in the player, it works fine, it just hits and exception that doesn't break anything. there too much code to share on Discord, so if anyone wants to take a shot at helping me trying to locate why it's hitting the exception, let me know ๐
@bitter forge Mirror
Because in Mirror you have full independent, and in photon u are dependent
Alright thanks
Say I wanted to have some logs for diagnosing whether someone using hacks (speed hack for example), should I log their position in database whenever they move? Or would this be inefficient, I could see the database filling up pretty quick if I did that.
If you are concerned about hacking you should give your server authority over positions. It can examine each one and enforce the rules without the need of a database.
A database is definitely not the way. I wouldn't concern myself with defending against hackers until you have completed some basic proof of concepts and tutorials. Networking is hard enough without trying to tackle hacking right out of the gate.
@bitter forge Purely on the ease of use side, API of PUN feels cleaner and PUN handles matchmaking, lobbies and hosting out of the box.
@spring crane which solution would require the least amount of code
PUN and solutions from Exit Games in general.
How are people handling NAT traversal/punch through/port forwarding for when players self host?
Photon bolt does the custom signaling via the room, uses standard stun messages/protocol for reflexive address lookup and handshakes...
So, STUN (which specifies you need a signaling mechanism). You can also use steam transport layer, something like that...
@gleaming prawn Sweet, ive seen that STUN thing while researching, not to sure I understand it but ill keep reading
any gamesparks GURU's here ? ๐
You will probably want to just post your question... even if there are they likely don't want to commit to an open ended Q and A without knowing what you are after. @inner prism
I always ss some good things as u explain above @jade glacier
what does this means writing read message directly to your states?
You have to first have buffers in place and reduce your simulation to states and ticks... otherwise that has no meaning. @fair cosmos
for example? send data only in time like 20 packets per second?
i think he means make sure your simulation has authority over time. (when to change state, when to trigger event)
i nvr have used buffers
without that it's like a car with two drivers :S
It is too large a question sorry. If you aren't familiar with the concepts of simulation and state ticks, the rest is going to have no meaning.
@slim ridge it makes sense
You should research a bit on how most games deal with simulation
Counter-Strike GO is a pretty common reference, but most game networking discussions talk about simulation and tick.
Once you reduce your game to tick based states/inputs.... those go into your buffers (history)
It is that numbered history that you are syncing, not the state themselves.
right!
Ticks are no the same as time btw
The specific example of doing it wrong is
if (hasAuthority)
RPC(myPosition);
}
RPC(Vector3 pos){
transform.position = pos;
}
That directly connecting the messaging to the state.
@jade glacier so i am totally wrong doing my game networking
and what can be the right?
All beginners are, that is why first attempts at networking should be considered learning tests.
yeah, atleast i came to know that i am doing wrong
Right is to capture your inputs and states on a tick, and sync buffers, and consume from those buffers.
if(_timeSpend > syncInt){
if (hasAuthority)
timespend = 0;
RPC(myPosition);
}
}
RPC(Vector3 pos){
transform.position = pos;
} ```
If you need more details you have to go internet for that. I don't have the 3 hours required to give a proper course on good networking here every time someone asks about this unfortunately.
any course?
nope
networking is not for anyone wanting easy.
You have to become an expert, or accept that you will be making mediocre networking and just do it wrong, or use a full stack like Bolt.
i am using Mirror!
Networking is one of the harder parts of game dev, and Unity gives nothing for tools at the moment outside of the preview netcode.
and i do not want to use that netcode
Mirror has no concept of simulation, you are on your own there. Mirror is a messaging layer and an entity lifecycle layer.
well i love mirror because as u said you are on you own there we are not dependent on it, we can do whatever we want
Just be aware that it will encourage the bad behavior of tying messaging directly to your states.
You have to make your own tick engine if you want to make a proper tick-based state sync.
Or don't, you can ignore that and just write directly to the current state. You will just have a mess of race conditions to deal with, and internet jitter/noise headaches.
But it will "work"
well i will look into that
What about communicating directly with .net sockets instead of using hlapi?
u may have seen TOm Weiland videos, he is making tut on this!
Unless you create a tick engine and ring buffer... there is no "easy" way to do it right.
ok
Photon Bolt does it correctly. You can do a tutorial for that to kind of see it in action to get the concepts involved.
Or just don't bother, and just do it all with messaging and call it good enough.
But you can't just fix that once you go that route. Proper networking starts with the simulation and buffers... messaging comes last. Mirror/Pun/Unet/MLAPI all put messaging first - so you are going to likely need to start over once you decide to do it right with any of those.
ok thnx!
hi i receive this browser error after testing my webgl build. im using awardspace to host player profile information https://prnt.sc/sqosdt
anyone have any idea what cors header "access-control-allow-origin" could be
yay CORS
i dont know how to fix it ๐ฆ but it probably means you turn off that same origin policy somehow or specificly allow requests to www.hoshi.io
I'm trying to implement the team mechanic still I've managed to make it so the first player who spawns are assigned to the correct team so they respawn but when people joined the variable isn't changed, I'm using "PV.isMine" to make sure I'm changing for the right player but for some reason the function is always false when a new player joins
I thought pun had teams built in, maybe not. You will want to make the team change a cached rpc, or have the master, or all clients resend it OnPlayerEnteredRoon @empty quiver
alright cheers
PhotonTeamsManager.cs I think @empty quiver
Ahh thank u how would I find documentation about this?
cheers
Just want to know if someone knows a good free hoster for server
Just want to know if someone knows a free hoster for server
Like herokuapp
what's wrong with heroku?
google cloud and AWS have free tiers that will serve your purpose provided you're careful not to exceed the limits
>> cross-posting in several sticky threads; please pardon the repeated message<<
We understand many of you would like to create multiplayer games / multi-user projects and are challenged by Unity's current state of netcode. We also acknowledge the netcode and workflow requirements can vary based on the projects you're building.
So, to help us understand how to best to support you, please share your thoughts in the survey below. The survey only takes about 10 minutes, and your feedback will help inform future product decisions. Click here to take the survey by June 8.
```<https://unitysoftware.co1.qualtrics.com/jfe/form/SV_dd8ShLNBj5oSSj3?Source=Forums>
@stray scroll their netcode thing
is such a fucking mess lol
2 years of 'talk' and 'pr management' about how bad the situation is
and still nothing usable
my dots networking lib i made works better than the built in one, without any code gen or any other crap they have
it doesnt suffer from cpu issues with delta computation
has individual priorities for entities
and is very bandwidth efficient, etc.
and i built that in what 3-4 months? they've put out something "somewhat broken and not done" in 2 years
what a joke
Oh and they made a new survey
What happened with the results from the old survey?
Russian hackers tainted the result... had to make a new one ๐
I need some help from anyone willing to think along with me.
I have a project that used to run fine, but the communication with the server stopped working.
The weird thing is, it DOES work when I open Fiddler to debug network traffic, but when I close Fiddler it stops working
I'm stumped.
Anyone? I have no idea what's going on
what have you done to debug the issue?
Looked at server IIS logs, send debug messages via Postman, tried debugging with Fiddler but you can see how that went.
It works in the Unity Editor
But all the latest version of our app that are publicly available stopped working
[] is the server sending data
[] is the client receiving data
[] is the client sending data
[] is the server receiving data
where does it break down?
it works when Fiddler is open, so I'd say sending?
wait no... I have no way of confirming what is going on since I can't recreate it with Fiddler open
do it with logs
The logs on the server aren't showing my activity
It doesn't show my attempts to log in with our app at all
is the client attempting to send the packets?
it should, but I can't confirm it because turning on Fiddler "fixes" the issue
use a log
i'm hoping you'll find that it's not attempting to send them and you can fix it easily. otherwise there's some issue in the transport layer (i think that's the right layer, could be wrong)
yeah, but the fact that opening fiddler "fixes" it seems to point that it's somewhere outside of Unity...
I talked with someone else who pointed out that Fiddler uses it's own root certificates for communication
Also, the Android version of the same build doesn't have the issue
But I'll see what I can bring up with logs.
But if anyone has any tips based on the above, please leave a ping
check your server at OS level it's probably rejecting due to certificate
thanks
trying to do a simple networked test on Oculus Quest and when i do a build, its failing to find and connect to the server. this works fine in the editor and the Quest is connected to the internet through the same wifi as my Unity computer. are there any special permissions I need to add to android player settings? This is the first time I've tried any kind of networking in a Quest build. I already tried setting "Internet Access" to "required" in the player settings...
You should indicate which networking library you are using
solved it... it was my fault! ๐ข
Hi folks, I have been away from Unity for a bit and I looking through options for networking in Unity. Last I heard Unity was in the middle of rewriting their entire networking structure? I am looking at a few different options for networking frameworks like Mirror, Photon, etc. Any other big ones now?
Photon Quantum (I'm one of the developers) has been released 2 years ago.
Photon is 3 (4) libraries, but those are the places most people start these days.
Unity itself still in promiseland
Mirror is there same architecture as unet
I think when most people say photon here, they mean PUN. But there is Bolt and Quantum that are also photon libraries. @lone jackal
this is great info, ty folks ๐
Mirror, bolt, pun, and quantum are all wildly different. So it's not just 'pick one'
You need to pick based on your game type, and whether you want a complete stack, or just a messaging/entity layer.
Quantum is the major outlier, and is the flagship product for photon. It's a deterministic engine.
Yeah, I plan to dig deep in each to see how I can mesh with them. Right now I am researching scalability. I am working with a few options for integration into Kubernetes and I love DevOps and things of that nature :). Atm I have some work done with websockets and scaling in k8s.
I am working on a bit of research for marrying DevOps and Game Development, normal apps are boring ๐
I am working with a few options for integration into Kubernetes and I love DevOps and things of that nature
With Photon you do not deal with this, unless you work with us...:)
If your goal is to release the game, that's actually one less thing to deal with
Except if you plan to host dedicated Bolt servers, then you may do that
If your plan is to develop/release a game, that's normally the last of your worries.
Although the COST of it should be considered
yep, that is where a lot of my focus is
containerization of unity and friendliness of the networking framework to scaling
so it can scale and not cost a ton
ideally though unity is not running at all in a container, and it's a dedicated server, but that would obviously start requiring things like physics engines on the server side
When you want traditional dedicated server you are normally talking about a Unity (or game engine in general) instance...
Which is NOT what you want when cutting costs is one of the goals..
No matter how well you spin up servers, they will cost A LOT
The point is, this is not really the only way to do accurate and reliable multiplayer...:)
I wonder what is Unity's base resource usage is in a headless state though?
Well, just running full game sim with physics is already a lot...
Whatever engine you get, if you run full sim on server you can never compete with a server that only handles input batching and control (where you can defer game validation based on automated replays)
We're always talking about 10x/100x more scalability... But... Whatever...:)
yep yep exactly
Mirror/Bolt are both bases on a Unity instance being the host (either listen server or dedicated headless)
Bolt comes with punch through + relay connection (through photon room). Mirror AFAIK works out of the box on LAN only... Or dedicated server... Unless they've added default support for punch, etc
Quantum is a deterministic game engine, so totally different approach.
PUN is relay based only
The correct answer for most people is Quantum, but it isn't really accessible to hobbyists.
Easier to start with (PUN2)
Disclaimer - I work on the Pun2 team, though not sure a disclaimer is needed when I'm not actually pushing it. ๐
Of all of the engines discussed, I believe Pun has the largest current number of games using it. But it does have caveats. Relay based state-sync and interpolation means lots of client authority, and no inherent lag compensation of any kind.
you can add Epic Online Services to the above
people aren't used to it yet so nobody's sure how well it works (probably very well)
Epic Online Services is to compete with Playfab and Steam (services) AFAIK
It is not at all for (online multiplayer) Gameplay implementation...
UE Networking is (lets say similar/equivalent in some aspects to Bolt and to some extent Mirror, but of course for people using UE)
mm yea it's more backend , transport is prob not part of it