#archived-networking
1 messages · Page 76 of 1
@solar garden reliable un-ordered is useful for everything which doesn't need an order lol
also you don't use reliable ordered for commands (if you mean like player input commands in an auth simulation)
I was thinking more of server commands, player inputs are sent unreliably ?
Can someone explain to me how UI works with the photon plugin please
You should ask more specific questions.
Thank you for the advice it turns out it was nothing to do with Photon
Creating custom networking with TCP/UDP sockets for learning purposes. Do y'all think it'd be a good idea to create a new thread for server-client communication in the client wherein all its Connect/Receive/Send stuff are blocking? As opposed to using stuff like socket.BeginConnect and I think socket.BeginReceive which accept callbacks.
depends on the rest of your client. if it's using async features your sockets should too. otherwise i recommend threads
alright, thank you!
I decided to go with a thread, doing UDP stuff
Assuming a game server is underloaded & ends up having plenty of CPU cycles to spare etc, are there any strong reasons for why you'd still want to limit receiving player state/event datagrams from every client (and using it to update server/authoritative state) to some fixed rate?
Like any strong reasons to design game servers to ignore (some) datagrams if they reach some absurd rate from some clients despite the server easily being able to handle the rates collectively?
plenty i'm sure. Best one I can think of is to eliminate spam from compromised clients or bots
but im pretty sure the DNS providerand network firewalls can take care of most of that
so there's not much reason to design such a limit into your game server?
i.e. the DNS and networks will fix that for you?
wow my tick based state sync just worked for the first time.
I was wandering If anyone could assist me with C# firebase for a unity project (I just need to know how to return a token to my backend)
right now the return type is firebase.auth.firebaseuser and I don't know how to best convert this into JSON because everytime I do it is returned empty (I assume it is a promise return issue but I'm no familiar enough with C#)
please ping me if you can assist, I can also pay for your time if that's allowed.
Hi, can anyone explain my why using structs with Sequential Layoutkind and Pack 1 and using marshalling to create a byte arry of it ends up with different results on Windows and Android ?
Thats part of my test code ```cs
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ExampleStruct
{
public byte byte1; //76
public float float1; //123456.12345f
public int integer1; //8763
}
var size = Marshal.SizeOf(example);
var arr = new byte[size];
var ptr = Marshal.AllocHGlobal(size);
Marshal.StructureToPtr(example, ptr, true);
Marshal.Copy(ptr, arr, 0, size);
Marshal.FreeHGlobal(ptr);```
and the resulting byte arrys
Windows : [76,16,32,241,71,59,34,0,0] vs Android :[16,32,241,71,0,59,34,0,0]
Sequential is not guaranteed to have the exact same padding
In different platforms
Explicit layout would do it AFAIK
@weak lava padding is not the same between platforms/compilers/etc.
Pack=1 just means "please attempt to this on 1 byte boundries"
but if the platform doesn't support it
or the compiler thinks different
no dice
additionally Marshal specifically deals with interacting with the native ABI for the platform, which is not the same between different archs/etc.
basically sequential + pack is useless for ensuring same memory layout everywhere
it's 100% legitimately absolute no use what so ever
sizeof(Foo) and Marshal.SizeOf(typeof(ExampleStruct)) isn't even guaranteed to return the same value
@gleaming prawn @graceful zephyr Thanks for the informations.
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ExampleStruct
{
public byte byte1; //76
public float float1; //123456.12345f
public int integer1; //8763
}
ExampleStruct example = new ExampleStruct();
unsafe {
byte* exampleBytes = (byte*)&example;
for (int i = 0; i < sizeof(ExampleStruct); ++i) {
Debug.Log($"{i}: {exampleBytes[i]}");
}
}
@weak lava
this is how to print/access the bytes w/o Marshal
but even if this turns out same in your case on windows/android, it doesn't matter
because it wont work for every case, and is basically useless
you need control layout by hand
INCLUDING manual padding bytes
lol... I like it (explicit)... Some padding gaps are super nice to fit in extra data when things start to get data-hungry....:)
ah ok that means with the use of Explicit and a defined layout, the results should be equly on differen systems ? like so cs [StructLayout(LayoutKind.Explicit)] struct ExampleStruct { [FieldOffset(0)] public byte byte1; //76 [FieldOffset(1)] public float float1; //123456.12345f [FieldOffset(5)] public int integer1; //8763 } Tha feels like a lot of noise for my scenario and im already using a different approach, but it is good to know how all that stuff works^^
@weak lava that layout looks pretty bad, as u will have unaligned read on both float and int
[StructLayout(LayoutKind.Explicit)]
struct ExampleStruct
{
[FieldOffset(0)]
public byte byte1; //76
// afaik floats are 4-byte aligned
[FieldOffset(4)]
public float float1; //123456.12345f
// same for Int32
[FieldOffset(8)]
public int integer1; //8763
}
you have 3 extra bytes (of padding) if you need some 3 new bytes
ah ok ^^makes more sense
Does it work with WebGL (I asume PUN, as photon has several different products)? Yes
??
safe to publish? I do not know what this question means
Sorry
Does PUN (as I said, photon is a company, not a product alone, there are several different photon products) protect against hacking out of the box?
Not much/not really
It's based in full client authority
It's very convenient for you to develop with though
anyone have s solution for my game that requires a friend(online) list/ pre-game lobby feature like csgo and fortnite where you wait and queue with friends?
@gleaming prawn thanks 1 more question, is pun2 more secure than pun1
no
It's the same approach
Photon Bolt is traditional client server (server authority), quantum is deterministic
These are safer against "hacking" (depdends what you consider here as well)
anyone have s solution for my game that requires a friend(online) list/ pre-game lobby feature like csgo and fortnite where you wait and queue with friends?
@weak plinth Hey buddy. You'll need to have a always active server : this has to be a server that responds at any time a client tries to connect to it. When the game is launched, you'll need to connect to this server and it'll give you the infos about your friend's list/ server's list. You can buy a server like that (not much a month), and you'll have to configure it all by yourself.
if it is serverless way it can help too
if it is active then it dont go cool so not waking up so much but if need always be up then you might need to think of keep alive or being warm up path
true
@vagrant marten i have a server and a database is on there i was just hoping someone already has a solution for this exact case as i dont wanna dive into sockets and such
@weak plinth oh sorry I didn't get you were at that point ^^ (btw this is fairly simple, when connected by tcp use server commands to just return infos, if you did networking already, don't worry you'll get it)
I do networking with mirror for the actual gameplay because doing tcp/udp socket stuff is just annoying
and time consuming
thats why i asked.
photon pun/bolt/quantum one of those should suit your needs
how do i call a function from a gameobjects script that does something to that player in their view
example:
Script 1:
//stuff
void MethodThatDoes() {
Debug.Log("did stuff");
}
Script 2:
//stuff
MethodThatDoes()
it shouldn't print "did stuff" in my console, but in their console
since it's their script, how is this done?
I guess this would be the channel to discuss mmo capabilities of Unity?
Since networking would be the bottleneck?
This is my first time working with unity however I am developer for like 10 years and been doing "servers" that suppose to comunnicate with players
it's not impossible to make an MMO in unity but it's ill-advised- you don't get the level of control you need. but this conversation is better suited for another channel
@atomic ingot
The level of control I need is something that I'm wondering about
Have you ever developed and released a multiplayer game yourself? As part of the team developing the network side of things?
Unity is as suited as basically any client engine is...
No, everyone got to start somewhere
No I have never compromised and this time will not be any different
hi, where can i send stuff from multiple players to a singular array which can be viewed from any player?
do normal arrays work? like if i made a static array variable would it work?
I was just wondering why someone said unity is not suited for mmo, I thought netcode will be a problem
?
the more in depth your mmo gets, the less useful unity is.
but are there any barriers that cannot be overcome?
The more.in depth your mmo gets, the less important any engine (as a single piece of software)
Unity (or unreal, or your-favorite-engine) is probably 1% of what you need for an mmo
whats an mmo
So basically, wrong questions
you wont know until you try
when it comes to raw code, I can handle that as long as engine will let me
I wonder if in 10 years it will still be the same question...:)
first barrier i encountered was the update loop. Since you can only modify the scene from the main thread you have to use async features or pass the data between threads
and when it comes to networking, fixedUpdate is completely useless
you have to do all of your timing in Update
If you start from the assumption you will use for an mmo server, go back 10 slots, start over
Whatever you say about update loop is just mambo jambo, this is not even were you start...
There's nothing wrong with using unity as an mmo CLIENT, nothing
well, unity is not a server side suite
No engine is
I wasn't going to use it a server, is that even possible?
lol yes but not advised
Well, for FPS games, that's normally how you do it
No, you did not getnit
you guys thought I was going to use it as both client and server?
i was talking about as a client
Sorry, that's all I can contribute. Just a humble opinion.
Nothing wrong with unity in itself. Just do not start with an MMO
It's the same question over and the ver, I've seen it for the past 15 years
im guessing he has already shipped some kind of online service before if he worked on servers
Just do yourself a nice favour, start with a cool game, simpler one
One you can finish alone
If he would be in a position to even start discussing about what it takes.to code an mmo, he would ask different questions...:)
Sorry, but there's people here who can do one...
No you are wrong, I have over 15 years of experience in development BUT i do not know much about unity
Just start with something smaller you like
no no no, sorry i have never started with small stuff, this is just boring
Lil
it's ok to have ambitions for an MMO, just be realistic about the milestones between here and there. it will be a lot of them
@glass osprey start with something simple like multiplayer pong 🙂
If you start with an MMO, you will get like <5% of the way and then give up
I am totally opposite of that
if I start with some minor stuff i get bored and quit
You have no idea what you're trying to build.
I do
not but I more or less know how this works in WoW
You can't both have not built it before and know what you need to build
Do you, really? :) Then why you ask here
Those two are mutually exclusive
good lord, I was asking if using unity will be a problem
lol dont come in here for encouragement
Encouragment you can get.on the self help section of the local library...:)
Here's the reality of the facts
You can't build an MMO as your first multiplayer project with no previous experience by yourself.
Simple fact.
If you think you can, you are delusional
Or it will take you so long that you will give up
And bare in mind I mean actual viable code that could support a launched game
anyone can download UMMORPG from asset store and "make" their "mmo" lol
so expect ~15 years or so
of work
see you in 2035 or so, best of luck
@glass osprey But sure, unity will give you problems.
If you try to make an MMO fully inside of Unity
not adviced at all
Same would be if you replace unity with ue
But you already said that would not be your idea
If you would be really serious, depending on the scale of what a single player sees and does, I do not see a big issue with unity.as the mmo game client
You should be worried about what you will actually use for your servers
Honestly, I didn't ask for people opinions of what should I do or what I shouldnt. I am perfectly aware of my capabilities. Why people feel so compeled about forcing their views onto others?
What would be the architecture for supporting shards, how to cope with stuff like 200.000 moving NPC's, 20k players.
I asked if just unity is capable to work as mmo client
@glass osprey Then go bother some other channel
About your last question: it's called experience
@glass osprey unity is that... sure, mabe, no, yes?
depends on what you do with it
just the fact that you need to ask that shows how out of your depth you are
You probably can't, but sure
but thats not your problem isn't it?
Nope
So like i said
Will unity work as an MMO client? yes/no/maybe
Depends on what you do with it
If you ask a more specific technical question, maybe you can get answered as well
For the question you asked, the answer.is, really, honestly, don't do an MMO
I already got one example of good answer from @slim ridge
Yeah, sure
@glass osprey if you want to use something to get u started look into mirror
they have a very big discord server also where u can get tons of help
which is more protected from hackers in android ? mirror or photon
i really need a clear answer for this question before i start making my game
I will be basing my networking code on WoW networking
what does that mean
yeah 3
@glass osprey What does that even mean?
Oh, perfect then rayan
Let's.go
With dedicated servers you need to pay.for physical machines to host every single one of your online matches
And that will get very very expensive
I do not have the mirror statistics, as I'm not one of their Devs, but I've not seen a single large multiplayer game on MOBILE done with it
Reason is not that it would not work,.it would...
ahh, so the majority is done with PUN, right?
It would technically work well for many games, arfuably
But it gets very very expensive to host servers to run an instance of unity
This is one of the reasons why people.go for:
- pun (servers are just relay)
- photon realtime + photon server plugin
- quantum
- forge (I assume)
forge same issue as mirror
@viscid tree there are 2 hidden relay server transport in mirror discord check them out to
¯_(ツ)_/¯
yeaH! obviously! the one relay is based on DR2 with direct connection module too!
What are the relay.options? Steam for pc is one,.right?
okay so let's say i published a decent android game with PUN2 Free and advertised it and started gaining a playerbase, will my game be vulnerable to hackers?
and if so, is there any way to prevent that or secure my game?
Rayan, with mirror, assuming.one.of the android clients is the server, in both cases it's a bit out of your control
okay one last question, can a hacker hack me by hacking my game?
????
like they can trace back the connection or sum
you sure?
@viscid tree ips are hidden!
With a.decent relay, no
client > relay > client
Not possible
whats a relay
dude just give up
If you want to go the route of relay based but client server, both mirror and photon bolt work
for real
simply relay is a server which allows your player to make rooms without port forwarding(but still u have to port forward on the relay host)
Port forward, really? :)
@fair cosmos port forward on android? lol
whats port forwarding
i say without port forwarding dude!
yeah i know, just asking
Hmmm
whats VPS
@viscid tree is this a real game, I mean something that you expect to be played?
Released commercially
I assume your 3 past games are real released games, with a decent track record.
nothing in mind, i'm just looking to see if it's possible, but yeah if i think of something i'm capable of developing, publishing and advertising
If not, nevermind what I said
meaning I know more or less how wow networking works
Have you worked at Blizzard?
i wish
It would be less fun than you think
why, they pay you right?
@glass osprey how does it work?
if it's a decent source of income sure
Sure, a job is a job
There better and more fun jobs though
There's great people there, of course, nice guys, etc
what kind of things do you do as an employee at blizzard?
Just rambling, really
wrong channel for this 😄
Yep
with mirror, how would I use the virtual void OnServerAddPlayer? I tried making my own network manager class by doing
using UnityEngine;
using Mirror;
public class CustomNetworkManager : NetworkManager {
public override void OnServerAddPlayer() { Debug.Log("TEST"); }
}```
but it just says `'NetworkManager.OnServerAddPlayer():' no suitable method found to override`
nevermind im dumb
i forgot the NetworkConnection conn argument
@sharp star go to Mirror Discord for further help!
You were connected first?
I assume you call Disconnect() right before setting OfflineMode = true?
Wait for the callback OnDisconnected() and try there.
Are you using PUN 2.18.1 (latest from asset store)?
Can't reproduce this in that version.
why doesnt this rpc function work? If i put things locally above it it works fine
here's the function
[punRPC] is above it
Because you call the RPC with one parameter (the ...ViewID in the call) and you don't have a parameter in the implemented method.
The error log for that should indicate this (but is not worded well, I admit)
hi, so i'm trying to change the isTrigger of a BoxCollider2D but it only changes for the player viewing, other players still see it as isTrigger, how do i overcome this?
do i add the BoxCollider2D component as an observable component to the photon view?
or do i add a photon view component to the gameobject containing the boxcollider2d
once the if becomes true, if the conditions are correct it still doesnt happen
so if it happens once, its true and when it happens again it's always false
RPCs are executed on a specific ViewID. You call photonView.RPC(...). That's enough to keep the context and you don't need to pass the viewID as parameter.
@viscid tree, Triggers are tricky. Code in Update() can not always reliably detect them, so you have to take special care to actually send them.
Most networking solutions have some way to specifically record triggers to send them.
ahh okay, so what do i do then?
also i fixed the problem but i want to see if there's a different solution
I've been working on my multiplayer game for 7 months now 😅
I miss coding singleplayer ngl, so Im looking forward to finishing it
@viscid tree, create a cache for triggers. serialize them along with other updates, send and repeat.
hey, so this isn't much of an issue but more like looking for a better method.
so everytime i test my game and stuff i build to standalone which takes about 2 minutes and i run the game in unity & standalone to simulate multiple players, it works but i literally get like 4 fps and it's so slow, is there a better way of doing this?
have a better PC xD @viscid tree
or maybe you can run all except one without rendering?
with what money
disable camera xD
disable the camera like the game's camera?
hello
ok
can anyone help please?
is there a more efficient way of testing multiple players
like preferably in the editor itself ?
@viscid tree What do you mean by testing multiple players?
scroll up i explained the question more clearly
If you want your question answered don't make people hunt down for it. Formulate it in one place.
hey, so this isn't much of an issue but more like looking for a better method.
so everytime i test my game and stuff i build to standalone which takes about 2 minutes and i run the game in unity & standalone to simulate multiple players, it works but i literally get like 4 fps and it's so slow, is there a better way of doing this?
Downgrade your graphics or optimize your code
Profile to see what's taking long
But if your world is relatively simple and your code is as well then your PC is just too shit
my question is how do i run unity for different players in the editor itself without building to standalone
like i simulate player1 in a tab and player2 in a tab
Test network code on the build that uses placeholders then, to have minimum build time.
for photon
the buuild time isn't the problem but is there a way for unity to do that
Idk what photon provides, lots of people do builds to multiplayer specific things
The EDITOR is heavir than a build
By a LOT
To test two "players" (you probably mean game clients) you need two instancews of the game
I guess he wants to run 2 player instances on the same client. Sort of coop.
like 2 player instances in the unity editor itself
You can either do like you are doing:
- build vs editor
- or use symlinks to run two editors of the same project
But that would be HEAVIER than what you have now
This is how Overwatch looked. https://www.youtube.com/watch?v=6sWKEkdcf48
like 2 player instances in the unity editor itself
Unity editor does not let you run two instances of the game
In PUN, or Mirror, or many of these libs, what you test are two game clients (game instances). Player is just mapped (most of the time) 1-1 with game client
The lighter you can do is:
- test with two game builds, run them in shitty quality settings, IL2CPP builds
IL2CPP is for webGL only right?
But I suspect it's your code that is currently too heavy
No... IL2CPP does not exist in Webgl
IL2CPP is the only honestly usable runtime for Unity for production
But anyway
Just for testing, mono builds should be fine
i mean i literally have no graphics at all just a bunch of squares and like 2 ui text elements
You either have a very very heavy code (yours) or a very very very bad computer
i mean i literally have no graphics at all just a bunch of squares and like 2 ui text elements
It's not the graphics, it's the CPU probably
Use the Unity profiler
identify what is running so slow in the first place
i did, it had a lot of green and a tiny bit of blue
???
Do you know how to read/use a profiler?
It will show you how long each piece of your code takes to execute in the editor
Try to read the Manual about it
Profiling is a basic programming concept
You need it
i'll look into it, thank you!
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!
i cant even find a reference to SetCountAllowance in pun1 docs
You guys know any Articles or examples for frame based/ tick-based networking stuff. Like this what Emotitron is doin for photon?
Valve's networking in Source might be interesting https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
The tick stuff itself is mainly just about numbering state/inputs and using that as the backbone for syncing
messaging <> state & input buffers <> simulation is the concept.
The change on thinking is focusing on reducing you game to a tick based simulation... The rest follows that.
For custom UDP networking, wouldn't Tasks generally be slower / less performant than Threads?
@viscid tree @gleaming prawn You can actually run 2 unity instances of 'almost' the same project
I use this all the time:
https://support.unity3d.com/hc/en-us/articles/115003118426-Running-multiple-instances-of-Unity-referencing-the-same-project
The goal seemed to be running 2 network clients on the same process to avoid overhead.
oh i thought people were talking about testing/running their games
@sonic marsh i think it'd also be possible to use something like sandboxie and have 2 editors running in separate sandboxes
maybe but that symbolic link thing works perfectly
ive created 4 copies before to hunt for a crazy networking issue
Yes @sonic marsh I mentioned the simlink trick
You can run two editor instances
What he was asking for was something else
@open trench Completely depends on what ur doing
Hi, basic question... how to separate the Server and CLient code? with specify #IF server #endif ?
Yes
hey everyone, can photon support chat and real time? i want to get multiple things
Photon PUN & Photon Chat
You can use both concurrently AFAIK, but with two separate App IDs
Photon chat uses even different infra-structure
@viscid tree, this looks as if you create an app on the dashboard. The appIds for Chat are not compatible with those for everything else.
Realtime, PUN and Voice are room based. Chat uses channels.
okay one more people my project was in photon 1 so i went to photon 2, right no nothing is working, the callbacks aren't working im som ad
@stiff ridge please help me
my whole project is ruined
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;
public class PhotonScript : MonoBehaviour, IConnectionCallbacks {
public void Awake() {
PhotonNetwork.ConnectUsingSettings();
Debug.Log("Connected");
}
public void OnConnected() {
Debug.Log("OnConnected");
}
public void OnConnectedToMaster() {
Debug.Log("OnConnectedToMaster");
}
public void OnCustomAuthenticationFailed(string debugMessage) {
Debug.Log("OnCustomAuthenticationFailed");
}
public void OnCustomAuthenticationResponse(Dictionary<string, object> data) {
Debug.Log("OnCustomAuthenticationResponse");
}
public void OnDisconnected(DisconnectCause cause) {
Debug.Log("OnDisconnected");
}
public void OnRegionListReceived(RegionHandler regionHandler) {
Debug.Log("OnRegionListReceived");
}
}
@viscid tree, stay calm and have a look at the migration notes. All of that can be fixed.
i did but the callbacks arent logging anything and there are no errrors
and i set the appversion in the server settings too
Are you registering that class instance with photon network somewhere? I don't see at a glance any calls to register the callbacks.
nevermind i just changed the base class to MonoBehaviourPunCallbacks
That works too.
I got an odd problem, I'm using TwitchLib.Unity and am having trouble with the OnMessageReceived event listener.
It will work when run from the unity editor, but not when the program is compiled to a standalone windows program.
anyone have any ideas?
if you make a development build you can see any console errors a standalone built might have
Awesome, I'll try that. Thanks
and if that doesnt work, the file paths to the full player logs can be found here:
https://docs.unity3d.com/Manual/LogFiles.html
I can’t seem to connect the profiler to a unity linux server that’s running locally in a docker instance. All other connections work correctly. I’ve exposed the ports. Has anyone managed to connect the profiler before?
is the TcpListener the c# equivalent of a ServerSocket in java
do you mean Socket ?
no the ServerSocket class
oh, .NET doesn't distinguish between client and server sockets the same way.
You create a Socket with various options.
but it does have classes on top of that:
TcpClient, TcpListener, UdpClient
Ah oke so these tcpClient TcpListener etc would be the more distinguished sockets
More specialized
why is the call back not being called?
using Photon.Pun;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class OnlineScript : MonoBehaviourPunCallbacks
{
public Text text;
public override void OnLobbyStatisticsUpdate(List<TypedLobbyInfo> lobbyStatistics) {
Debug.Log("lobby changed");
text.text = $"<color=#BAFF88>{PhotonNetwork.CountOfPlayers}</color> online";
}
}
i have lobby statistics on, also tried using MonoBehaviour and ILobbyCallbacks and still nothing
how do i create an array viewable by all clients?
example: client 1 appends a string to the array and client 2 when they access the array, they will find the string
Never made use of that particular callback, not sure.
You are using this while in the lobby? and not in a game?
@viscid tree
yes while in the lobby
I'm using Photon 2 to network. I notice that there is some lag between the time when I enter a command on the build window and when I see the corresponding action take place in the editor (and vice versa). Is there a way to cut down on this lag, or do I just have to deal with it? My game needs low lag for pvp (think about how much rage people feel when they are hit with online lag). Actions like movement and jumping also see a few frames of lag, but lag is very obvious when comparing this arrow, which has a PhotonTransformView that should sync it across computers.
That's the internet. You will see a delay of about ping + buffers + interpolation
Hello . Did anyone worked on Network Discovery Component ?
I have hardware device which connects with android mobile (wifi) . I want to know hardware device IP address from unity.
hi
hi want to send a post request to server and receive data. i tested the api on post man and it works. but when i try in unity i get null can someone tell whats wrong with my method?
https://hastebin.com/qevevisuxu.cs
it works in postman
@weak birch share your unitycode
Hello guys im trying to figure how can i connect to my server build from a client
I followed the manual of NetCode, but i ca get it working using my game as client and server,
What i want to do is to have a server build so connect from different clients,
but i am not able to figure how to do that
Also the networkEndPoint let you et the port but not a custom IPV4 Address, so i will not be able to set my server in a custom ip
the manual doesnt explain anything about server builds
just that can be done!
what i just want to do is to be able to move a cube throug a client that connects to the server, and be able to connect other clients to it and each of them move a cube
@shell talon i fixed it thanks i was missing s in https
@marsh bison Things that need to be approved by the masterclient are problematic, since you need to hop through the relay to another client and back instead of just connecting to the server.
If you are just telling other clients something and not waiting for a response, then it's just normal internet latency stuff
@weak birch What are you doing in Networking? 🙂
It's not her first API rodeo 😛
Hello .
I have hardware device which connects with android mobile (wifi) . I want to know hardware device IP address from unity.
It is the address of the machine running Unity
You want the local address inside of your Wan I assume.
Get your machine's IP address.
@jade glacier my app is an android app generated from unity.
That android app needs to connect with another hardware on my local network. So I want to know what’s the IP address of that hardware . I’ll use that IP address of hardware to send rest calls
What is the "hardware" in question?
You said running from Unity, so I assumed you meant the editor.
If you want android devices to find one another, you will have to implement some kind of network discovery. But if the "server" is a fixed machine... just get that local IP address from its settings.
This is the device https://github.com/aromajoin/controller-http-api/blob/master/README.md
I want to get the IP address automatically
automatically can mean anything really
I don’t want user to search ip. Or if I can get all the ip addresses on my local network
I can show in the drop down box
It sounds like you want network discovery of some kind
yup, Network Discovery is the answer
Do you know any weblink to do that?
Ok
but that would be embarrassing for both of us 😛
Look at the old Unet NetworkDiscovery for some ideas
Or what mirror has
it isn;t sure to work, but it is one way to "find" other games on a lan/wan
Ok
On the other end , it’s not mine code.
Have you opened routers configuration page? It shows all the ip addresses that are connected
Yeah, you tend to do that often with networking. Usually to open a port to your server.
Yes . But how to do that with unity. I’ll search more. I’ll update you if I’ll get some success 😎
Have you worked on iOS app ?
yeah, my one learning game was android/ios
https://play.google.com/store/apps/details?id=com.emotitron.TeapotAvenger&hl=en_US It wasn't networked though. I did start a MP Descent 2 style shooter that I did test to run on iOS using the old Unet HLAPI though, which was working pretty well.
@spring crane Is there a faster/better way that would cut down on the lag? A setting I should change?
There are calls you can do to tell PUN to send everything asap, but it doesn't affect everything IIRC.
Does it affect position, rotation, and object instantiation/destruction?
I don't remember. Could also try adjusting how much PUN buffers before sending
@spring crane How could I change the amount the PUN buffers? I tried increasing and decreasing PhotonNetwork.SendRate and PhotonNetwork.SerializationRate but I wasn’t sure it did anything.
You can call service on the transport at any time, but it isn't likely the source of latency.
PUN2 is a relay based system, meaning all traffic goes to the relay server, and that sends the messages to each player.
PhotonNetwork.NetworkingClient.Service(); will tell your client to push anything in the hopper out the door. But that in most cases is gaining you a small number of milliseconds if anything.
Should I call that at the end of my update functions? How do other multiplayer games, like FPS games, get everything to sync so closely? (for the most part).
As your netcode gets better, you will find you keep ADDING latency. Buffers are how you make the jitter of the internet not show up for users.
It is a bigger question than that. Update should have nothing to do with Networking - networking should all be based on Fixed timings, but generally speaking that is as quick as you can get anything out the door regardless.
Everything should be in FixedUpdate ?
I would be less concerned about flushing every update, and more concerned about getting your entire game state compressed down into one byte[]/packet in whatever way you can.
Bigger question than I can answer here in a few lines. It is the core of networking simulations.
You are just learning, so right now you are just using messaging to transmit and apply states.
Which ultimately is wrong and you will throw it all out, but you have to go through that step first.
If I want the player to move right when they press ‘d’, how should I get them to move on all computers? Currently, I have an if(PV.IsMine), a key checker, and a force on the player, which has a photo viewer, photon transform viewer, and photon rigidbody2d viewer. It works, but it has noticeable difference between screens.
only use one one those, not both.
Both are just meant to show you how to code a sync though, and aren't actually considered production tools.
The latency is the internet. The internet IS latency. That is the heart of game networking and why it is difficult.
It isn't just copying values over the network, it is about hiding that latency of the internet from users, and it is a massive complicated topic.
@jade glacier Should I remove the photon transform? I thought that since unity’s physics is not deterministic the positions would get out of sync.
Use whichever sync gets you the best results.
is there no networking support right now for Unity?
not built into engine no
How do i make something in an [RPC] work only on the local side?
not sure why but this only returns the true value for the first player and any other players "PV.IsMine" is false
oh lmao
here are the lines of code
Is that code on the player?
how do i store data inside an array from a player that can be later acquired from any other or the same player?
@viscid tree you can either control all entries and deletions via rpcs or see if your networking solution has synced arrays/lists
RPCs are so confusing, i did it and literally can not figure out how to access it back again from a different script
this line of code doesnt affect the local player tied to that variable. How do i make it so it does?
its confusing to explain only decreases that variable relative to the client the game is being played on
Id put it inside an rpc function that is called to all players therefore every client will know the health value of that player as well as the player
Its in an rpc function @empty quiver
can I see?
sorry whats this part for?
do i not need it?
I don't think so at least on my script I haven't but obviously ur game is different
Hi there can anyone help me set up a simple login in system using mirror. So I can just have 2 scenes 1 for login and other for the game. I click the Host/Client button and it loads a player prefab into the game scene.
yes I am
@empty quiver still doesnt work
can u send ur playerhit function please
u are referencing the health variable from the same script correct?
and ur sure that the function is being called?
yes, all the other things in the function happebn
have u trued "colplayerscript.currentHealth -= 1"?
either side?
the variable doesnt change
my issue isnt that the function isnt happening, its that the variable is only decreased for the local player
can u explain how its suppose to work in relation to the game?
so if a player hits another player, one health is taken away. If the health = 0 the player dies
lets say each player has 3 health, but now if player 1 hits player 2 twice, player 3 will still need to hit player 2 3 times before they die
i want it so if player 1 hits player 2 twice and player 3 hits player 2 once, player 2 will die
why am i getting this error?
Received OnSerialization for view ID 1002. We have no such PhotonView! Ignored this if you're joining or leaving a room. State: Joined
@empty quiver
so if a player attacks another player that value of the player who they just hit isn't synced to everyone else?
is everyone in the scene at the time the first player is hit?
@weak plinth
it does
yea but the variable should be synced with everyone else at all times right?
but for the other ppl who joined it wont be synced for them even if its synced to the main player
thats my understanding
the death only works for the colliding player
i thought of an alternative
how do i trigger an event on another players script through photon
The RPC isn't working for that? @weak plinth
Not sure what you mean, I haven't been following the conversation. But RPC is the basic method for remote execution.
ill try explain it
emotitron knows more about PUN 2 then me he'll probably be able to help u
the colliding players variable gets changed, but on the colliding players client their variable isnt changed
@jade glacier
I'm pretty busy working on Pun2 at the moment (ironically) so can't promise I can help. Keep the question as simple as possible if you would.
thats as simple as i can get it
There are two colliding players though, so already a bit lost. Might be better to define them as local player, remote player, and owner.
oh okay
First step regardless is determine your authority structure
who has authority over what state values?
Who determines damage? And who broadcasts that damage, vs who broadcasts the damage results.
local player collides with remote player, variable only changes for local player
What is the variable?
And who has authority over this variable?
So the local player has authority over its own health
Who has authority over damage inflicted?
The other player?
local player changes the variable for the remote player
Back that up
you have to define your authority, or I can't help
Who defines the damage?
Each player determines damage for themselves? Or do other players send "I damaged player X"
local player inflicts the damage to the remote player
So the attacker defines damage
yep, its a midair boost
Ok, so the conversation starts with the attacker RPCing out "I hit player X for X damage" or whatever
yes
You can target that player, or broadcast to all.
i broadcast to all
it gets the script from the player it collides with and spawns a particle
Attackee gets that RPC and locally triggers a damage method of some kind. That in turn causes a health change. The Attackee then broadcasts "My health is now X"
You are welcome to look at the SNS beta, it does all of this
But its not an easy read
If your code is easy to read I can look
But I literally am at work right now, so I am already WAY longer into this than I can afford to be
The conversation you are after is
Attacker RPCs out "I hit player X"
Attackee gets RPC... applies damage to health... RPCs out "My health is now X"
Way too little context there to know if that conversation is happening or not in your code
it does happen
Then it should work, unless you have a bug in your code
but the damage and audio only happens for the local player
Are the RPCs firing correctly at least?
Debug.LogError("I Did a thing");
the particle is spawned for both local player and remote player
If the RPCs are firing as expected, then its other non-networking code that is the problem
if the RPCs aren't firing, then there is an issue with your targets or logic.
okay so its the non networking code?????
Depends if the RPCs are firing correctly or not
this is what happens
colplayerscript.currentHealth = colplayerscript.currentHealth - 1;
is the thing thats mucking up
@jade glacier Debug.LogError("I Did a thing"); is called but the problem still persists
If the RPC is firing as expected, then the networking is right.
Might want to post your code in the regular help channels, more people there to look at it.
the health variable stays at 3 for the remote player
if the RPC arrives, and you set the value in response to it... then something else is fighting with your sync.
why am i getting this error?
Received OnSerialization for view ID 1002. We have no such PhotonView! Ignored this if you're joining or leaving a room. State: Joined
Are you getting a wall of them, or just a few?
It typically just means that your photonview updates for an object arrived ahead of the instantiation call.
It shouldn't be an error, it should just be a warning.
i figured out what the problem is, i built my unity and ran on both instances but they aren't connected somehow? i changed the appId to 0.1 in serversettings
but the specific problem is this OnRoomListUpdate callback doesnt execute
@jade glacier
also i referenced MonoBehaviourPunCallbacks
also Photon.Pun & Photon.Realtime
Possibly a bug, I am not familiar with the OnRoomListUpdate usage and expected behavior. @stiff ridge might know if what you are seeing is normal or a bug.
They are in different regions?
there aren't any errors coming up, also i turned on support logger, also no logs that a room has been created
That is a common issue with the editor, that even with the DevRegion can be a problem.
how do i know which region im on?
Turn up the log settings in Photon's settings
to informational or whatever it is
and it will indicate in the log which region the editor is connecting to.
You can also force the region in settings to make sure they have to be in the same region
oh i see that
also it just says something along the lines of asia,au,cae,eu,in,jp,kr,ru,rue,sa,us,usw,za
pick one for testing
set the FixedRegion for now if Dev Region may not be working for you.
Did it not automatically have a value?
the dev region?
Make sure you are building Development Builds for Dev Region to work
Other pro-tip... do all of you networking development on a skeleton version of the project.
networking dev and long builds are not friends
im getting this warning
PUN is in development mode (development build). As the 'dev region' is not empty (eu) it overrides the found best region. See PhotonServerSettings.
is that bad or normal?
yup
alright cool
its letting you know that all users will connect to that region
and not their best region
ah okay
it worked, but im still getting this warning Received OnSerialization for view ID 1002. We have no such PhotonView! Ignored this if you're joining or leaving a room. State: Joined
also it only logs when i move my player
also im getting this msg before it PUN-instantiated 'Square(Clone)' got destroyed by engine. This is OK when loading levels. Otherwise use: PhotonNetwork.Destroy().
It is there constantly? Then you have some bigger problems yeah
You are doing something that is destroying that object it seems like
ill show you the code that instantiates the player and stuff
manager script: https://hastebin.com/xeqironutu.cs
player script: https://hastebin.com/yureredamo.cpp
I don't know that part of PUN2 well, so probably can't help you there. But looks like you have something destroying the object, either in your code, or through a scene change or something
I can't read all of that sorry. I am working as I check here. questions have to be very specific, and I can only answer them if I actually know.
Others might have an idea though.
@viscid tree , the game version (and PUN version) value(s) will separate players into so called "virtual apps". In other words: We don't match players of different Game Versions to avoid incompatibilities.
https://doc.photonengine.com/en-us/pun/current/lobby-and-matchmaking/matchmaking-and-lobby#matchmaking_checklist
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!
i set the app version to 0.1 in the server settings
i noticed that only the person who created the room can view the other client and himself
and an interesting "ghost" client
check out this thread https://forum.unity.com/threads/photon-unity-networking.101734/page-5
there's a guy who's having the exact same problem
OK, i finally fixed the issue
it was a mistake on my end, i was loading the scene twice
Ah
my problem from yesterday still stands, this line of code changes the currenthealth variable of another player. But the code doesn't change the variable for the remote player, only for the local. The rpc is working properly so what am i missing?
Colliding player isn't being sent as part of that rpc. Too many unknowns there to say.
That actually might be it, thanks!
Is there a way to make collisions happen as an rpc?
how can i replicate this?
@viscid tree, the issue you quote in that forum post is from "tobiass, Mar 1, 2012". are you sure this is still not solved? 😉
Hello, I'm new to unity and currently am making an online trivia game and I need help in the networking side.
I tried many things I found on the internet and some worked but I couldn't add a timeout to the connection - would terminate and 2 seconds and freeze the screen.
And some do have a timeout without freezing but I cant exit the callback or setActive GameObjects if it fails connecting(The code terminates without any errors).
Anyone got a client that can has a custom timeout without freezing and I can call setActive with it terminating or can help me?
In the image you can see my scene and I want to show the Connecting To Server text and the loading animation until a connection error occurs and then hide the connecting and show the error with both of the buttons, how can i achieve this?
this code only works if one player is in the scene https://cdn.discordapp.com/attachments/497874116246896640/724592014263320587/unknown.png and I dont know why @spring crane also it is on the player prefab
Do other scripts on the prefab report IsMine correctly?
Odds are you are leaving out some important detail
I think this is the issue
it keeps saying object reference not set to an instance of an object for these 2 lines
but not the first player
@spring crane
I believe its reported correctly on other prefabs how would I check?
You could log IsMine just before the statement
alright thank you
I am having an issue with downloading and caching Asset Bundles from Amazn Web Servives and then Unity reloading old versions of the Cached Assets but not the newly updated ones I deployed no matter how I try to clear the bundle cache . Could anyone offer some insight ? I wrote a post on the unity forums . https://forum.unity.com/threads/how-do-i-clear-cache-asset-bundles-when-using-unity-web-requests-to-download-them.917885/
I'm having this issue with a project I've got. I have my game working fine with different people joining. But sometimes, there aren't enough people. So I wanted to get a few AI Agents in the mix.
I've got that part done. Where I'm having a problem is, my system is setup so that the scoreboard and the UI reflects kills and scores to the player. However, none of my bots are being registered as players since they're being instantiated in different levels.
My question here is that is it possible for me to add the bots as players in PhotonNetwork.playerlist?
So the system could work seamlessly.
@rugged parrot Could you make another list, maybe "AgentList" or "RanksList" that combines the PhotonNetwork.playerlist and the botList? That seems much easier than trying to fool Photon into thinking that the bots are players.
I already have an agent list.
The problem is that when I do some tasks, say updating the scoreboard, it utilizes the custom properties laid out by photon for it's players.
A lot of those logics for different systems are linked that way to photon. So for that reason, for me at least, fooling photon seems easier 😓
If I could apply the custom properties of the players to the bots, that'll help as well
If not converting them into PhotonPlayers
If you can read properties from bots and players, it seems like it would be easier to "get" information from PhotonNetwork.playerList than it would be to "set" information. If Photon does not expect people to do stuff like this, I would expect it to be extremely hard. What properties do you need?
I'm using player kills, death, score, teams and weapon. That's for the most part.
Also, I'm assuming C#'s HashTable class and Photon's HashTable classes are different, right?
Cuz I've used Photon's Hashtable and created the systems. So it'd be a pain to create another one for bots since it's deeply intertwined. So I was wondering if photon allowed us to create photonplayers and add it to the list.
@rugged parrot I'm sorry. I cannot be of any more help to you.
Oh no. You've by far suggested and helped me the most out of all. Thanks for that @marsh bison.
I'm glad I could help. I try to help the previous person before asking my own question.
Why might Photon destroy a gameObject without a destroy? Some [PunRPC] functions of mine that are called in the script governing player movement destroy the player. Calls to the below function often lead to the player being destroyed, but it is annoyingly fickle. I am trying to add a dash ability to my game, which temporarily freezes the player in the air until they choose a direction and release the mouse. I figured constraints would be the way to achieve this.
[PunRPC]
private void SetRigidbodyConstraints(bool x, bool y, bool r)
{
if (x && y && r)
{
rigidbody2d.constraints = RigidbodyConstraints2D.FreezeAll;
}
else if (!x && !y && !r)
{
rigidbody2d.constraints = RigidbodyConstraints2D.None;
}
else if (x && y && !r)
{
rigidbody2d.constraints = RigidbodyConstraints2D.FreezePosition;
}
else if (x)
{
rigidbody2d.constraints = RigidbodyConstraints2D.FreezePositionX;
}else if (y)
{
rigidbody2d.constraints = RigidbodyConstraints2D.FreezePositionY;
}
else if (r && !x && !y)
{
rigidbody2d.constraints = RigidbodyConstraints2D.FreezeRotation;
}
}```
I don't know exactly where the source of the bug is, but this function is part of the problem; deleting the calls to this function allows my program to otherwise work (just without the constraints being set).
Anyone knows the equivalent of OnPhotonPlayerActivityChanged in Photon Pun 2? I can't seem to find it in the docs. That seem to be in Pun v1
@drifting ridge, there is a callback when a player leaves or joins rooms. Those are used in PUN 2.
The player in question is passed to that method and you can check player.IsInactive.
We are about to release an update which adds Player.HasRejoined, which makes it more clear what is going on.
@marsh bison, you did not get any errors logged on the console / player log? That should usually point out the line of code that fails.
@stiff ridge ok thanks. Any estimate on when it will be released?
When a player disconnects, is there a way to see the ttl countdown of that player so that I know the time remaining for the player to join back into the game?
Am I right to say when the ttl timer is over, the player can no longer rejoin the game?
Does rejoining actually take into account of the room Is Open and Is Visible properties?
No, there is no way to see the individual ttl countdown per player. There is just another callback, when it's over, so you can only estimate the timing.
When the ttl is over, yes, the player can not rejoin the game. If the game is open and visible, the spot is free and this user or another could get matched into the room.
Rejoining works even if the room is closed and invisible. Technically, the player is keeping the spot in the room but is just inactive (not getting any current messages).
There is just another callback, when it's over, so you can only estimate the timing.
@stiff ridge
What is the this callback?
And thanks I understand how rejoining works better now.
Also CleanupCacheOnLeave happens after the ttl timer is over, correct?
Any estimate on when it will be released?
I hope today. Not entirely sure, as there's always one more feature we want in 🙂
The callback is actually a set of two: OnPlayerLeftRoom and OnPlayerEnteredRoom (part of InRoomCallbacks)
Yes, the CleanupCacheOnLeave refers to the server's Event Cache. It's the mechanism which we use to keep instantiate (and other events) in the server for late joiners and re-joiners.
This is cleaned up when a player is gone for good.
I see. New feature are always nice 🤩
Ok I understand. Thank you for explaining as this clears up a lot of confusion for me.
One last question, when I use LeaveRoom(), this makes the player be gone for good, correct? Meaning the ttl is no longer valid for the player and cannot rejoin?
@stiff ridge
@drifting ridge, LeaveRoom has an optional bool parameter "becomeInactive". It defaults to true but you can set it to false to leave a room skipping the ttl.
We meant this to be for turnbased games and async games, so if you'd enable a playerTTL, we assume you want to use it.
@stiff ridge Ok thank you!
@spring crane this is the debug message that appears https://cdn.discordapp.com/attachments/497874116246896640/725084054541828177/unknown.png
@stiff ridge Sadly, I do not get an error message. The player is simply destroyed, and a bit later is destroyed on other windows of the game. The only time that I use a destroy in my code is with bullets getting destroyed when they hit something (or get replaced by a newer bullet), and that does not seem to have anything to do with the dash ability or the SetRigidbodyConstraints function. Is there anything that can lead to Photon deleting a gameobject? Is there a better way to temporarily freeze a rigidbody2D in place?
Nothing in the code posted should lead to a destroy, so I would stick a debug in front of every Destroy() call in your code and check the trace on where the destroy action is coming from.
Are you sure it is being deleted? And that your code isn't teleporting it way off screen?
@jade glacier It is being deleted. The camera is a child of the player, and the camera stops showing the scene (no cameras in scene), and in the Hierarchy the player disappears.
Yeah, then track down every .Destroy() call and see what is causing it in the trace
@jade glacier The only time I use destroy is when destroying bullets, which does not seem to have anything to do with this, and it checks that the tag is "Bullet", which for the player it is not.
Something has to be destroying it somewhere, if it is getting destroyed. I would put a log before every call to Destroy in the entire solution, rather than spending too much time trying to guess.
Nothing in the code you posted is doing that, so it is outside of anyone's visibility here.
@jade glacier Are there any event handlers or other places where PunRPC functions cannot be called?
not sure what you mean by "places"
I actually don't know the limitations of RPC, I never use them. But I would expect they need to exist on the root with the PV.
It should be in the docs about RPCs where they need to go.
@jade glacier I think that this sort of thing would happen if the player disconnected. What might cause the player to disconnect?
You should be able to get log messages about disconnects, are you seeing those?
Assuming you have turned up the message level in photon settings to show all information in the log
PUN logging FULL ? Or Network Logging ?
@jade glacier Does SocketUdp.Disconnect() mean that the connection failed? If so, then the network is failing when I try to call the [PunRPC] functions related to the dash. Why would they cause it to disconnect?
Not sure, but yeah - I would think a disconnect message means you are sending something it isn't happy about. What are you sending in that RPC?
I know this is broad, but what is the best way to do p2p? I want a vr thief simulator, where one person is a thief and the other person has to catch them before they steal everything. Im thinking using photon bolt, but I'm not sure on how it works or setup. Does anyone know?
@icy otter Sounds like a fun idea! While this discord is a great place to ask questions, videos are much better for starting off. I found this series very helpful: https://www.youtube.com/watch?v=02P_mrszvzY
Welcome to this new tutorial series on creating multiplayer video games in Unity using the Photon 2 PUN plugin. For this lesson, we will show you how to download, install and set up the Photon 2 plugin in your Unity projects. Before you follow along with any of the other lesso...
Ah ok, thank you! I'll give this a watch later
@jade glacier In the hopes that fewer RPC functions would make it work better, I combined the dash stuff into one function, and it actually seemed to make the program disconnect less often. The code that moves the player due to the dash is in Update. Should I try to cut down on the number of [PunRPC] calls I use? It still occasionally disconnects, but less often.
[PunRPC]
private void FreezeDash(bool b)
{
if (b)
{
rigidbody2d.constraints = RigidbodyConstraints2D.FreezeAll;
weaponObjects.transform.GetChild(useWChoices.IndexOf(usingWeapon)).gameObject.SetActive(false);
if (Handy.GetChildWithName(this.gameObject, "DashArrow") != null)
{
Handy.GetChildWithName(this.gameObject, "DashArrow").SetActive(true);
}
}
else
{
rigidbody2d.constraints = RigidbodyConstraints2D.FreezeRotation;
weaponObjects.transform.GetChild(useWChoices.IndexOf(usingWeapon)).gameObject.SetActive(true);
if (Handy.GetChildWithName(this.gameObject, "DashArrow") != null)
{
Handy.GetChildWithName(this.gameObject, "DashArrow").SetActive(false);
}
}
}```
too much for me to read in this chat window. But if you are only sending a bool that shouldn't be causing any problems. Unless you are somehow sending that 3000 times per tick.
@jade glacier I do not think that it is being called that often... This is the event handler:csharp void OnGUI() { if(PV.IsMine){ startDash(Event.current); } }
This is the function where the [PunRPC] is called:
private void startDash(Event currentEvent){
Vector2 mousePos = new Vector2();
Vector2 point = new Vector2();
// compute where the mouse is in world space
mousePos.x = currentEvent.mousePosition.x;
mousePos.y = cam.pixelHeight - currentEvent.mousePosition.y;
Vector3 v3 = new Vector3(mousePos.x, mousePos.y, 0.0f);
point = cam.ScreenToWorldPoint(v3);
if (Input.GetMouseButton(1) && dashable && initiatePauseOnce)
{
PV.RPC("FreezeDash", RpcTarget.All, true);
initiatePauseOnce = false;
}
else if(Input.GetMouseButtonUp(1) && dashable){
initiatePauseOnce = true;
PV.RPC("FreezeDash", RpcTarget.All, false);
HandyPun.allLog("Up Mouse Dash");
dashMousePos = point;
Vector2 tpv2 = transform.position;
Vector2 diffv2 = dashMousePos-tpv2;
diffv2 *= dashLength/diffv2.magnitude;
dashMousePos = diffv2 + tpv2;
inDash = true;
dashable = false;
}
}```
How often would it be called? I would think only once when right click down, once when right click up.
@marsh bison by the way, do u think my game sounds fun to play?
@icy otter Yeah, it really does. It would be a great party game. Add some funny physics interactions and ragdolls, and you have a viral game.
Haha thanks!
@jade glacier I think that I got it. I think I was calling too many PunRPC functions. Unfortunately, as I expand the game, I will only be adding more. It will be tricky to avoid calling so many that it disconnects.
@marsh bison What are you trying to do with that OnGUI thing? That seems bad
I wanted a right click down to start a dash. I thought OnGUI was how to do that.
I would really look into how often that is firing, and it most likely isn't the way to do this
Use Update with an Input condition or input events of the new input system
Afaik OnGUI is called whenever pretty much any potential interaction with the old immediate mode UI system can happen, which could potentially include just the act of holding some button down
Ok, I can switch to update. You will notice that I have a bool initiatePauseOnce that is sort of a lazy way to stop it from calling too often.
How can I get Event in Update?
Oh I misread as startDash being the RPC
In that case it's fine, though a bit unconventional to use OnGUI for that
I really don't think you should be hitting RPC send limits that easily if you are using common sense
Maybe mobile devices might struggle a bit
I had a few other unnecessary RPC ‘s that we’re called every frame that I didn’t really need that I got rid of.
How many where you calling? It would take quite a few to force a kick.
@jade glacier I made a singleton with a PhotonView that allows me to get debug.Logs from all players. There were two calls to that, three [PunRPC] calls that set an int, and I had a PhotonNetwork.Destroy(bullet) inside of a [PunRPC] function.
Might it have been that last thing?
I hope you arent making bullets networked objects. No idea of that is part of the problem, but it's a terrible idea.
In pun2, when I'm the only player left in the room (hence the host/master client) and I leave the room, why doesn't the OnPlayerLeftRoom callback is run?
@drifting ridge, this is what the docs say for OnPlayerLeftRoom:
/// Called when a remote player left the room or became inactive. Check otherPlayer.IsInactive.
Locally, there is the call of IMatchmakingCallbacks.OnLeftRoom
I’ve been working on a game for a while now and I’ve been avoiding a problem but not I need to solve it. How would I create a mobile game that runs on a large server?
What is exactly the question?
How would I go about making a large online multiplayer mobile game
If you are trying to create an online multiplayer game, first thing to do is START with multiplayer from the first moment.
Second thing: do Not start with "a large online multiplayer" game
you will not finish it.
Start with something simpler...
THEN, answers:
- check PUN2 (photon), Mirror, and other options for multiplayer SDKs
- looks for tutorials on Youtube
Should I not use UNET?
- make sure to start with something very simple (if you have no experience with online multiplayer development, take this as professional advice)
Should I not use UNET?
UNet has been (abandoned) deprecated for a while already
Unity has absolutely no proper multiplayer built-in.
They are starting over for the 3rd time, and it's not nearly complete.
Ok thanks for the help!
Mirror is the open source branch of old UNet (with improvements)
So UNet tutorials more or less still work (should) for it
For beginners, the usual choices are PUN2 (photon), Mirror, Photon Bolt.
Is it possible to make a international game for iOS with unity?
how do i make the collision object be known by all clients?
Is it possible to make a international game for iOS with unity?
What do you mean by international?
If you can have multiple languages? Of course, it's your code that will do that.
Nothing to do with Unity
Unless he means regions?
Can someone explain to me how the team manager works in PUN 2 please I've looked at the documentation but its still just as confusing
I haven't actually used it. Which part of the docs is confusing though?
@jade glacier Which objects are networked objects? Is it the ones with PhotonViews?
yeah, anything with a PV - be it a scene object, or PhotonNetwork.Instantiated
bullets typically are events
I dont know how to create a team
also for some reason my health is updating in the code like it prints that that the health slider is going down in value but visually it doesn't go down
You either aren't telling the UI to change, or you have other code fighting with the networking code locally.
would u use this to define a team?
Im 100% its not something to do with the networking
its works on a another scene that I have made that doesnt use the same player
I have this in the update function
and health is being changed ONLY by the incoming RPCs for objects that you don't own?
My guess is you aren't IsMine testing your local player code, and it is running on un-owned players as well.
for the most part yes but I made a coroutine to test if the health slider decreased when the health value decreased
but even with 1 person in the scene the health bar never changes visually
Not sure glancing at the docs how you join a team @empty quiver
it changes in the code but not for the ui
this is what im using to test the health
Nothing else is trying to adjust that slider anywhere?
only here but this is only called in the start function
Dunno, something we aren't seeing is acting on that.
Docs that seem to touch on the JoinTeam() part of teams.
Side note, I would rethink that coroutine. Better to have your Canvas have its own tick that generates callbacks if you are going that route.
Its just for testing
so the teams are predefined and you get players to join teams by changing a value of a team to true or false
For testing, just stick it in an Update then, no point adding complexity to your basic tests
Not sure how teams work with the built in thing, you know more than me at this point on that topic.
I don't see your coroutine calling SetHealth btw
Should this not be calling the SetHealth() method?
its in the update method also yes that works a lot better
it doesnt update as fast now which is good because it doesnt need to cheers
this is what my update method looks like
You are starting a coroutine in Update? That isn't doing what I think you think it is doing though.
I think I figured out what the issue is I think its changing the value of the prefab and not the game object in the scene
That would do it.
I cant seem to reference the game object in the scene it keeps using the prefab
that did it just found the object with the tag health and got the slider component from it, thanks for the help
You will have to set it at runtime most likely
There is no reference until you run and spawn the player.
So in your players Start() you will likely want an IsMine test, and assign it from there.
That coroutine still needs to go, you will be spawning like 60 of those things a second.
Hey guys, can someone teach me networking in unity because i want to make a multiplayer game and i don't know how to do it without using UNet(I know just a liitle bit of UNet, i heard they're gonna remove it and i want something stable for my game) Game Topic: Top Down Shooter.
No one will likely do that that for you, anyone who knows this stuff is way too busy working. You will need to do tutorials for libraries like Mirror, Photon Pun2, and Photon Bolt - then ask questions.
^
i used the oculus integratiion kit, how can i make it so my movmement is syncronised with photon bolt? do i just need to derive it from the photon thing instead of monobehavior?
@stiff ridge weird I didn't receive any notification and waited the whole day... But that works! Sorry I missed the docs I remember looking through it a couple of times. There were times I happened to be scrolling through the docs of Pun V1 🤦♂️
Will check into that, but pretty sure we didn't touch that. Might be some other race condition in play.
Can you paste the actual log error?
And where are you calling that from in your code?
That was changed a while back if I think it is what it looks like. If it was working before, you may have been calling it at a time before the object had completed initialization.
We removed some code that did a brute force scene lookup that was expensive, if the basic find failed.
But it should only fail if users are trying to access the ID before the object has been registered.
@weak plinth
You can uncomment that code in PhotonNetworkPart.cs to see if it restores that to working. If so, I would be interested to know where in your callbacks you are making that call from.
We may just enable that block of code again - but it is a bit expensive. I think you are making use of the find before the object actually has initialized.
If anyone has any ideas what can cause this strange error, It would be much appreciated.
Here is my code which sends a put request with data:
string json = JsonUtility.ToJson(report);
UnityWebRequest req = UnityWebRequest.Put(StaticVars.BaseURL + "/user/scores/score", json);
req.SetRequestHeader("Content-Type", "application/json");
yield return req.SendWebRequest();
Here is what the webserver receives in the correct case (almost every user):
REST Request - [HTTP METHOD:PUT] [PATH INFO:/user/scores/score] [REQUEST PARAMETERS:{}] [REQUEST BODY:{"userId":xxxxxxxx,"packId":38,"userName":"xxxxxxxx","totalTime":43}] [REMOTE ADDRESS:xxx.xxx.xxx.xxx]
And here is what the webserver receives from one specific user (OS Catalina version 10.15.4):
REST Request - [HTTP METHOD:PUT] [PATH INFO:/user/scores/score] [REQUEST PARAMETERS:{}] [REQUEST BODY:PUT /user/scores/score HTTP/1.1Host: xxx.xxx.xxx.xxxUser-Agent: UnityPlayer/2019.4.0fl (UnityWebRequest/1.0, lubcurl1/7.] [REMOTE ADDRESS:xxx.xxx.xxx.xxx]
One user's request body is somehow the request URL and the request headers concatenated, which is so weird and I have no clue why
try using UnityWebRequest.Put with a byte array instead of string and see how it behaves
I originally had it with a byte array and changed it to string the first time I got this error. It's the same problem 😦
do you get the same result with POST?
catalina is terrible for games anyways and it broke quite a few
I will try post but it's difficult because I don't own the catalina machine so I am using a legit player of the game for testing lmao
also the game is in production already xD
oof
@slim ridge When I use post, it looks like the string gets urlencoded for some reason
well since it's in production the first thing i'd do is look for this specific case in your server code and manually parse the body :S
then work on getting a catalina machine
I guess I really just need a catalina machine
I don't even know if post would work on one, and I'm using spring which automatically parses json into the object, so it will be very annoying to do any sort of manual parsing
UPDATE: It might be some firewall setting on the person's router, because the error message shows the data that got sent in the packet was correct, but it isn't received properly on the webserver. The only way that can happen is something in the middle changing the data
it's probably some system call that's not acting the way unity expects
or that
saved by user error 😄
anyone knows if you need to lock a socket with a mutex when sending data? multiple threads will be sending data
anyone know how to double nat traverse using a library or something?
Ight, I need some help with Mirror, so when i use my host button i start the host and my player spawns and everything is good, but if i exit and host again i spawn 2 players, how should i fix this? I use the basic code from dappers tutorial but i then tried to change it up a bit, (just spawning a player instead of an empty object), but when i end the host and host again it spawns double characters,
EndHost function:
public void EndHost()
{
networkManager.StopHost();
landingPagePanel.SetActive(true);
OtherUI.SetActive(false);
}
@delicate parcel join the mirror discord for help there
ok
anyone here familiar with PUN2 ? Is there anyway for me to send data to a specific player who is not in a room?
Nope @wanton scroll
are you sure? I'm just trying to pass a connection string for a private friend match
You want a player in a room to be able to talk to a player in a lobby?
Need some professional advice. Am I goin about this all wrong? So I want to design a real time Multiplayer game and would like it to scale pretty well. What I'm doing now is making a game in Unity that doesn't rely on Monobehaviours. Monobehaviours will pretty much be only used for visuals but not core game mechanics. The big hurdle in this case was to utilize System.Numeris.Vector2 and not Unity Engine.Vector2 (and ofcourse writing custom physics to achieve the behaviour we want). The dream is that when making the server we can use the exact same code the client is using on the server to recreate the game on it's end to ensure the players are in sync and not cheating.
Am I going about this all wrong? I know there are systems out there that will run a version of the game on a unity server, but unless im wrong they seem to be on very efficient.
@wispy thorn that's not the wrong direction, no. That's exactly what we do with photon quantum.
It's just a ton of work (own physics, own navigation, so forth)
So doing this for a single game is overkill
I am using photon for a small multiplayer game and want to have a timer in the game, that is synchronized for all players. How can I do something like that? Should I choose one player that runs an extra script for that or is there any way the server can manage that?
Id have it inside ur player script and use an RPC function to broadcast it to everyone depends how the timer is gonna act tho
I want to have a day and night cycle, and therefore I have a clock. And obviously that needs to be synchronized
I think u could do that with an RPC function
Id use a coroutine to keep track of the time and have that method in a RPC function that broadcasts to every player in the lobby and anyone who joins
PV.RPC("RPC Method", RpcTarget.AllBufferedViaServer); I think this is what u would do to get it to work with every player in the scene and who ever joins
Time is a very lazy thing, so you could just send an RPC when new players join to get them up to speed (use OnPlayerEnteredRoom() on the Master), and send out vary infrequenct RPCs of the time.
That would be a better method wouldn't take as much resources
I would strongly advise against using coroutines like that - they are a debugging nightmare and just don't gain you much. They still fire on the main thread. They just get deferred to an Update timing that is after the normal Update().
If you have a main game loop in an update, have that check Time or deltaTime and send based on progress of one of those values.
well I only need to update the time when a player joins. Each player has the clock methode themself
They won't fall out of sync very quickly, so you probably could just sync once. But if you are concerned you could just send and update every second or something.
they wont get out of sync
Unless the time of day affects the game simulation, then you might want to embed it into your sent messages.
But it sounded cosmetic.
as long as the rpc function is sent at the same time to everyone I think it will be fine
It will not be tick perfect, for that you would need your sim to be tick based and serialize/deserialize/apply the time on tick. If it is not part of your simulation or anything determnistic in nature.... just an RPC to the target joining player when they enter will do fine.
clients will all be within a few hundred ms of agreement
well I am using Time.deltaTime
I think that would work fine 😄
@gleaming prawn Thanks for the feedback!
I created a new IPEndPoint, new IPEndPoint(IPAddress.Any, 0);
What's the minimum action required to make it actually assign a port?
got it: re-assign it to Socket.LocalEndPoint after calling Socket.Bind 👍
Anyone know why Socket.ConnectAsync has odd behaviour. Does it always call the completed event, even if it completed synchronously?
had a funny line
its okay
but it still weird
the server is sat waiting to accept connections
the server is a .net core app
then in unity I have a Connect button
it says it completed successfully, but the server doesnt show a connection attempt
only when you stop playing the unity, does the server then say a connection was attempted
sounds one side is stuck at a blocking operation
the thing is. i know the server works, as i had a net core client connect and send / receive data
the only difference really is that unity is running mono
i bet if you look really closely you'll find more difference
could be as simple as your IP changed since then
loopback
like i said. the server shows the connection attempt, but only when you press the play icon in unity to stop playing.
ive probable messed up somewhere
will keep digging
Can anyone help me? I'm trying to put multiplayer in my vr game with photon bolt,but it doesn't seem to be working. If youd like to help me out, please send me a dm :/
All networkers we need you to make arkas the best game in the world, joking, but still we need you to make a game with multiplayer system who wants to join the dm me
Anyone know a good way to remove the first line in a text? To fade out the first sent message in a chatwindow.
guys for someone who knows mirror networking i can't switch to my next canvas its a prefab and its kinda hard to explain heres the video the only problem is that if i join or host a game it doesn't show up : https://www.youtube.com/watch?v=WMJS7sVp2FQ&list=PLS6sInD7ThM1aUDj8lZrF4b4lpvejB2uB&index=6
@velvet tulip mirror have their own support discord, much better help there
oke thx
what would be the best way of going about running a dedicated server thats always active whether players are in it or not
from what im seeing photon and other programs only have lobbies that end after the player leaves
You would need to have a bunch of servers set up and running all the time i beleive
Photon bolt does p2p where on person acts as the server and a client
But i cant get my head around it
@sly fable run ur own servers
for some reason when a player attacks another player the value of the slider on the player they hit doesnt decrease in value even though there health goes down but when the client decreases there own health the health bars value does decrease
I think this everything that is relevant
hi guys, I am using photon networking in unity and I don't understand: how can I connect to my friend server, I need to pay more money for global server or somthing like that
or should it be with ip?
someone pls?
Which Photon? Pun?
No one is a "server" with Pun, the relay is the server. All players are clients to that Relay Server.
@tropic creek Just follow a tutorial, it will show you how to connect via matchmaking
The photon cloud and matchmaking will connect you will your friend
All your data passes through the cloud and you can have 20 connections at a time for free
This is for PUN
Your buddy can make a room
Is there anyone who wants something like photon in terms of ease-of-use, but allows you to push code to the server?
Photon allows that also
how do i find out what player is colliding with another through the server?
I can't find any documentation for the mirror/unet [server] command. Does anyone know what it does? It's in the context of putting it above a function to denote something, like [Command] for something you can run on the server as a client and [ClientRPC]
@sly fable Start servers as players connect to your matchmaking server
how do i trigger an event on another player's local game
Event as in a method?
yea @spring crane
RPC is the common name for something like that
im just confused because the server never knows what the colliding player is
@hallow perch IIRC warning is thrown when client attempts to run anything marked as [Server] attribute
Thanks. I have worked it out by trail and error now.
so the method doesnt work @spring crane