#archived-networking
1 messages ยท Page 68 of 1
I could swap the data onto an object without photonview as well
Any idea to make a leaderboard
is there a graph like this that explains the whole HLAPI structure but includes all the components HLAPI have?
Hello there, a 250 mbps bandwidth Dedicated Server will be able to resist a multiplayer that is sending to the servrer and to the client for example 250 vector3?
every time (the players)
Rent our E5-SAT-2-64 server. It is a perfect choice for deploying website and application hosting environments, and comes with anti-DDoS protection.
This one, will be able to resist more than 250 players that sends their position to the server all the time?
heyy
i can see my animations over locally when testing but other players cannot see it over the network
You are using photonAnimatorView? @gloomy meteor
yes
@jade glacier animations work perfectly fine locally
But why would they not sync/play over the network?
You dragged that sync into the PhitonView list of onserializeviews?
You did the tutorials?
Dunno then, sorry. You have a bug somewhere.
Because that's not networked
yea but i have the photon animator view right?
should it just not sync automatically?
Yes, unless something else you have going on is fighting it
nope nothing
Code isn't magical, you have a bug or conflict somewhere.
how many people uses Unity Multiplayer intead of Photon? in %?
but how come if i have a bug it works locally? i am not syncing any additional data over the network
You're gonna have to debug every step of the process and see where things are breaking.
oh
bro do i need to call rpc to call the animation booleans?
@frozen canopy I think you can count on your hands by how many people are using Unity Multiplayer if you're referring to DOTS NetCode
I refer to Unity Default multiplayer system that has NetworkManager NetworkManagerHUD, NetworkIdentity, etc...
Maybe @gloomy meteor For the SNS extensions I use passthrough methods for triggers, play, etc.
Looking for suggestions on networking tools for database interactions, in-game log in, adding items, retrieving data, etc.
Is Photon fully scalable?
I've swapped to PhotonNetwork.LoadLevel but my Lobby script will still not show up in DontDestroyOnLoad
I think I fixed it. I figured all photon ids would automatically be unique, because that actually makes sense. I tested it by changing the id by code in start, but it didn't like that. I changed it in inspector and it seems ok
I have the back end written in PHP, and a front end CMS to populate the SQL DB. Just wondering if there is an integration tool specific to Unity that the community prefers.
@nocturne jungle if you don't have multi-user interactions, you should think really hard if you need it at all
can anyone give me a review of https://github.com/Cysharp/MagicOnion
if anyone has used it
I'm considering migrating some of our microservices
How to make that the Player is moved by the Server in Photon PUN?
@frozen canopy By the relay or the masterclient?
Since PUN game rooms are hosted by a master client (initially the player who made the room unless it has been transferred during runtime) and the game servers itself are hosted by Photon and therefore are not accessible, you are not technically able to implement authoritative movement logic.
However, you could make the master client act as a "server", though that can sometimes be pretty complicated.
For example, sending local inputs (wasd, spacebar etc...) to the master client who then calculates the next positions & rotations etc... and then proceeds to send it back to the client who then applies those.
Though that can be quite unstable in most cases, for example when the master client disconnects / has his game frozen or crashed.
Anyone know how to bypass the "please enable JavaScript in your browser" using Unity Web Request?
If I build my online Photon Game and play it, my Player cant join the Room!
"can't" ?
@frozen canopy There is no server in PUN2, unless you start writing server plugins for the relay
The relay IS the server, but it is a server that has no knowledge of your game, it is just there to manage connections and traffic between clients.
The Master Client isn't a server, it is just a client that has been handed the baton saying it is the master - which is just to give you the ability to call one of the clients the final word, and indicates which client will own scene objects.
Server authority movement with PUN shouldn't be tried without server plugins. You don't want to treat your master client as if its a server, the latencies involved will be very disappointing.
"can't" ?
@jade glacier Yes
I mean that doesn't say enough for anyone to help you
There its work
Dunno
You are giving nearly no info about your code. So all I can say is you have a bug.
Have you done the pun getting started tutorial?
Yeah
From InfoGamer?
Here @jade glacier
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;
public class NetworkManager: MonoBehaviourPunCallbacks
{
public GameObject[] spawnPoints;
void Start()
{
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
PhotonNetwork.JoinLobby();
}
public override void OnJoinedLobby()
{
PhotonNetwork.JoinOrCreateRoom("Room", new RoomOptions {MaxPlayers=2}, TypedLobby.Default);
}
public override void OnJoinedRoom()
{
int randomNumber = Random.Range(0, 1);
Vector3 spawnPoint = spawnPoints[randomNumber].GetComponent<Transform>().position;
PhotonNetwork.Instantiate("Player", spawnPoint, Quaternion.identity);
}
}```
And PlayerNetworking:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class PlayerNetworking : MonoBehaviour
{
public MonoBehaviour[] scriptsToIgnore;
private PhotonView photonView;
// Start is called before the first frame update
void Start()
{
photonView = GetComponent<PhotonView>();
if (!photonView.IsMine)
{
foreach (var script in scriptsToIgnore)
{
script.enabled = false;
}
}
}
// Update is called once per frame
void Update()
{
}
}
That are the relavent Scripts
what server library would you recc for turn-based games?
I would explore cloud services first
If you can avoid hosting any metal boxes of your own that is best in most cases.
im just starting out with adding multiplayer to my fps, can sb please reccomend me a good tutorial/other means of learning how to make shooter pvp?
Bolt is going to probably be your best first thing to try for a proper competitive fps
what is bolt @jade glacier
bolt is for visual scripting
what does it have to do with making a game multiplayer
@vivid owl the reason i recommended magic onion is that you'll be able to author server-side compatible code from inside the unity editor
which in my experience in turn based games
is very valuable
you will waste far less time on marshalling/remoting problems in disguise
when it comes to stuff like login, just use AspNetCore's identity framework
it will cover 99% of your usecase
but as soon as you need to author something like a matchmaker, you will waste so much time not having it in-editor
otherwise few people are trying stuff that is self hosted
it just sin't the way normals do things
I see
I do need a matchmaker as well
and I already have a login server written in Go
which I'll be using to generate JWT tokens
no
what else
we're going to just go through
and think, is this valuable
because a game doesn't need JWT tokens
authentication is something that's needed
you'll just be stuck adapting to stuff that doesn't really matter
the world has a lot of auth systems
there's a login server, a server that handles CRUD operations and fetching static data, and battle server written up already
nobody makes video games with go, so you will find zero packages for it
okay, describe battle server to me
like for an existing web app game?
okay, battle server, what is the client
for the battle server
other go code?
it's an embedded battle server
yes
it sounds like this thing is written
I'm thinking of replacing it with MagicOnion though
mostly because I need to find polyglot developers to assist with the project, if we're using both
and that could be difficult
you will find zero yeah
but
i think if you have a thing that exists
it's a different story
if this game works, today, and it exists
it took me about an afternoon to get aspnetcore running from the unity editor
with kestrel
and another afternoon to get SignalR to work
however, i never tested it with il2cpp, where it will almost certianly not work
yes
this changes everything
and yes, we're using IL2CPP
does MagicOnion work well with IL2CPP?
anyways, I'm also currently using Kubernetes to handle all my services, and thinking of adding Agones controller to the stack
i'm a lot more likely to believe
that neucc authored something that works on il2cpp
I checked the docs, it seems like it does work on IL2CPP
although you need some additional tooling
anyways, how do you run ASP.NET Core from editor?
from what I know, the editor itself uses Mono, even when the project type is IL2CPP
are there guides on how to do this
here i got something special for you
it's not really a framework
just open sample scene and hit run
make sure you have two game views open
one set to display 1, another set to display 2
thanks
This is what my example does
you can click on the networking game object, and if your computer network is correctly set up, you can seamlessly change between no transport and networked signalr transport
also observe that it is simulating two game clients
in one editor
with the appropriate point of view
without cloning your project
and it is clearly turn based
because it is 1D chess
and it just uses kestrel
I see
i'm not sure
this is the best i could do for the ideal multiplayer game ergonomics
that is totally self hosted
nice
but is hosted (i.e., multiple game instances per single process)
but you can see i just use the aspnetcore DLLs
these's a lot of magic here though
well
the thing is
developer ergonomics and microservices
don't go well together
I think mocking/dependency injecting parts of the microservices could work
the whole point is to avoid
for current dev cycles, I've been spinning up minikube pods
"and then you visit this website""
i just think that
if you get a unity developer
and you utter the words docker or kubernetes or whatever
they'll just space out
they'll be like, this isn't for me
the whole point is that they hit the play button, and things work
true
TBF, we have multiple developers on our team
there's a clear separation of backend and frontend in our teams
I don't think there's any fullstack devs, whatsoever
I just ask one of the members on the client team to run stuff for me if I want to test things
which, I will say, is ergonomically horrible
Is there a way to use Terrain collisions with NetCode/UnityPhysics/DOTS?
You should do that locally, not via the net.
How can i have a like a input filed that the player can enter their username and then later use it in-game? (MULTI PLAYER GAME)
@ me if you know to do that
@amber trench there are dotween pro assets in your repository, is that allowed?
Anyone know how to bypass the "Enable javascript" warning u get when web requesting to an url that requires it?
Hello, will changing the values of:
PhotonNetwork.sendRate
PhotonNetwork.serializedSendRate
improve my player syncronization?
You should do that locally, not via the net.
@stiff ridge should be done in the server which syncs the simulation to the clients, but adding the terrain in Shared Data (Convert to Client Server Entity) seems incompatible with the old terrains
@frozen canopy yes, and at the same time it will incur in a lot more bandwidth use. You need to understand what is being sent, etc.
There are other ways to improve "player synchronization"
Depends on what are the issues you have now.
Yep, i saw a way by sending the player position to other clients via RPC
is that viable?
or it will use A HUGE amount of bandwidth?
Can i send a video so you can see the exact probleem that i have?
is that viable?
No... RPCs are not to be used in high frequency, they are worse
Can i send a video so you can see the exact probleem that i have?
No... As I discussed with you already, these are a bit more complex than you think. It's good you are willing to learn.
I suggest you take a step back and try to study resources about multiplayer game development.
It's difficult for me to "answer". You need to be able to understand a few basics so you can ask the "right" questions.
The game and m ultiplayer itself is working perfectly
Thats just 1 little mini-bug
that i dont know how to fix
There are many good developers in this channel, but most of them will only answer these "right" questions.
Thats just 1 little mini-bug
It's probably not a bug
Yes, this is jitter
Network sends are jittery, this is the nature of the internet. You can do two things:
- interpolate OR
- extrapolate
SNS would likely solve that for you, but it is in Beta so the docs are light
I think the photon view even has an option for you (for interpolation, for extrapolation you'd need to include player input and process that yourself)
But emotitron's SNS gives you much much better control of this
its all on the tick, so that kind of jitter would go away, in exchange for some other hurdles
Be sure with whatever you are using, that you are simulating in Fixed, not in Update
misusing those timing segments results in jitter with networking as well
where can i cahnge the interpolation and extrapolation? i don't remember @gleaming prawn
Not sure if it's available as a checkbox... I mentioned the basic concepts you can use...
They are easy to implement (if not there already, I think the transform view does interpolate)
SNS implements these AFAIK.
I do not work directly with PUN, which is what you are using.
OMG just saw that i miss-removed the component PhotonTransformView fromt the player...
can it be the issue?
@gleaming prawn
Nop, with PhotonTransformView looks even more jitter
If you have a manual implementation, you do not need the transform view
These are mutually exclusive.
Transform view moves the transform for you... if you had something working without it, it's because you wrote some code for it...
If you follow the basic tutorials you should have no jitter
Now its working pretty fine
just reduced the speed of the player
just a little bit
Can i perhaps see a character controller code that you might have written for a tick based networking system in your games? (doesn't matter what type as long as it's tick based)
I am looking for an example that every tick responds to multiple frames
I'd like to see how inputs and subtick info is handled in detail
How can i see the Player number that are inside a Specific room from another Scene?
(using photon)
Besides photon and unity's build in networking what other networking solutions exist today(usable with unity) for a VR shooter multiplayer?
Most will be, but you will have to do a lot of the wiring up of things yourself
I'm right now doing work for Exit looking into expanding some tools for Oculus - but that is pretty early.
I don't mind wiring up
the important factor is versatility, scalability and readability
Not sure any of those words go with Oculus ๐
Hey guys
Quick question.
I have a Unity.Transport Driver and it is getting one ScheduleUpdate at each fixed update frame.
And I would like to minimize the latency, is it a good idea to schedule a second update somewhere at the end of the frame in LateUpdate (with some flag ofc., so it will not update if there was not any FixedUpdate at the current frame)? Then I can wait for the job to get finished at the next fixed update frame.
And the whole idea is to minime the latency as I said, aaaaand it should "force" the queued packets to be sent... right?
void OnJoinedLobby()
{
for (int i = 0; i < roomNameList.Count; i++)
{
roomOptions.MaxPlayers = 2;
roomOptions.IsOpen = true;
PhotonNetwork.CreateRoom(roomNameList[i], roomOptions, null);
}
PhotonNetwork.JoinRoom("Room8");
}```
This doesn't create 10 rooms in the Photon Lobby, it asks me to first call the "OnJoinedLobby" or be the master client or something, how can i fix
you can only create/or-BE in ONE room from a client
You cannot create multiple rooms from one client.
When you create a room, you also JOIN it automatically.. You cannot create a second.
Have no idea what you are trying to achieve, but this is not how you use photon.
Yep i know now no problem
I want to be able to make several rooms with 2 or 3 players of capacity @gleaming prawn
and that a player can choose what room to connect
and see how many players there are in each room from th elobby
and choose a room
@ocean ledge Mirror has several projects going with VR https://assetstore.unity.com/packages/tools/network/mirror-129321
Any advice on Nagle's Algorithmus? I know tcp is not rly common in games netcode, but if tcp ,is it used with Nagle's ?
My understanding is that you should be disabling it. Mirror networking has dealt with that recently with their TCP transport
Yep, we disable it by default, although that was put in over a year ago (Jan 2019).
Yea meant recently as in the history of networking solutions ๐
Alright thanks :)
What happens if I use a MonoBehaviour instead of a NetworkBehaviour? What's the difference?
How many digits should have an integer Client ID?
@gray pond is mirror good enough for real time fps?
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;
public class NetworkManager: MonoBehaviourPunCallbacks
{
void Start()
{
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
PhotonNetwork.JoinLobby();
}
public override void OnJoinedLobby()
{
PhotonNetwork.JoinOrCreateRoom("Room", new RoomOptions {MaxPlayers=2}, TypedLobby.Default);
}
public override void OnJoinedRoom()
{
PhotonNetwork.Instantiate("Player", new Vector3(140, 190, 0), Quaternion.identity);
}
}
```How I can let the other player join on the cords 600, 190, 0?
Get a player count in OnJoinedRoom and use that to pick the spawn point? That won't account though for players leaving and others arriving after that. You probably would want the master client to manage spawn points.
Ok. I did it. But now I have this Error:
Assets\Photon\PhotonUnityNetworking\Resources\NetworkManager.cs(30,22): error CS1501: No overload for method 'CheckSphere' takes 1 arguments
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;
public class NetworkManager: MonoBehaviourPunCallbacks
{
public GameObject[] spawnPoints;
void Start()
{
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
PhotonNetwork.JoinLobby();
}
public override void OnJoinedLobby()
{
PhotonNetwork.JoinOrCreateRoom("Room", new RoomOptions {MaxPlayers=2}, TypedLobby.Default);
}
public override void OnJoinedRoom()
{
Vector3 spawnPoint1 = spawnPoints[0].GetComponent<Transform>().position;
Vector3 spawnPoint2 = spawnPoints[1].GetComponent<Transform>().position;
if (!Physics.CheckSphere(spawnPoints[0]))
{
PhotonNetwork.Instantiate("Player", spawnPoint1, Quaternion.identity);
}
else
{
PhotonNetwork.Instantiate("Player", spawnPoint2, Quaternion.identity);
}
}
}```
@jade glacier
So fix that
Reading basic debug errors is a bit off topic for networking. That is more a question for the regular Unity coding channels.
I would strongly recommend not trying networking until your have a firm grasp of Unity and. C#...
Or this is going to be very slow and painful.
Ok. ๐ข
@gray pond is mirror good enough for real time fps?
@ocean ledge Sure. You'll have to implement Lockstep or rewind yourself, of course, but the networking is up to the task.
cool! thank you ๐
Yeah, thansk
Actually I'm making an fps multiplayer game, battle royal and I am using photon. The problem here is how can I use it to make a working lobby and the match....
A question
Also, is there a way I can get a players name?
Idk, I haven't configured the game for now, I'm still on the lobby
Ok, thanks
You want to make a lobby where players can connect, right?
With a maximum of players
Oh ok
So
You must create a new scene and give it the name Launcher.unity
Then
As I did for my game, create a script
Named Launcher
(After all I am just saying what I saw in a tutorial time ago, you can find these things online)
Done?
Ok...
Actually, do you know how to instantiate the player object and get his/ her name?
So,
Here
Is easier to show than to explain
Thanks
๐
Help pls
Is there anything wrong in this network class? https://hatebin.com/dzpkdqaboq
I'm able to send data, but the SendData function doesn't return (it doesn't Set the sendDone event...)
The Debug.Log("MMM"); doesn't show
And Unity Freezes when it finish sending the data to the server.
I noticed that the callback SendCallback doesn't even run...
Which multiplayer solution is best?
Depends.
What game are you trying to make?
@wise creek
In fact there's a detailed post about what you should do during the UNet depreciation
Hi, I would like to load certificates from android device so I can send a secure https request to my backend server.
But given code returns empty certificates collection in Unity. In plain windows c# console app it works.
Do you know why?
using (var store = new X509Store(StoreName.Root, StoreLocation.CurrentUser))
{
store.Open(OpenFlags.ReadOnly);
return store.Certificates;
}
@wise creek https://forum.unity.com/threads/what-are-the-pros-and-cons-of-available-network-solutions-assets.609088/
Thanks. @weak plinth
I know it's not my place to say but 99% ||(in my case 3% why god)|| of problems you encounter, no matter about scripting or others, Googling gets you the answer.
I know! There are so many questions where the answer is a simple unitydocs or forum or stackoverflow that can be easily searched. That being said, I understand it's hard for newcomers and they might not know of those resources.
I do wish people would use these channels for help finding the right directions to look. Way too many people coming here looking to have their hand held every step of the way and have other's debug and write their code for them.
Once some directions are suggested, people really should head back to google with that new knowledge.
I agree
@tropic adder i see that you are using Photon, how do you spawn your players? for ex when i spawn them some players spawn on the same spawn position, how can i fix that?
I think he is the wrong person to ask, since he is trying to sort that out himself.
He's sorting rotation not translation.
yep
idk how to fix that, i have 2 spawn points and sometimes the player 01 will spawn in player 02 spawn point
You can have the Master be responsible for giving out spawn points, and have players stay in limbo until they get one from the Master. Or you can have them do an overlapsphere test or such and choose their own spawnpoint based on crowding...
By spawning do you mean Instantiating?
there is no native way, since there is no server.
I don't know about Photon, but brackeys has a FPS tutorial and in there somewhere he talks about managing spawns and spawn positions... the short answer is you instantiate a player at a random vector3 that has been clamped.
ye @tawny edge
So it does fall on the dev to decide how to deal with where players spawn
UNET FPS stuff will be different, because there you code the server, and the server does the spawning
in PUN2 the relay is the server, and it has no game simulation - it is just a relay.
with every client
You could have an area right like two points x and z and choose a range.
You first have to decide what is the spawn position authority.... the player, or the master client
Or you can make a Photon Server plugin, but that is getting a bit more advanced than any new dev probably wants to get when starting
Was isOccupied static? Cause I think it has to be if many different script want to access it with the same result
This should explain it (it doesn't use photon, it uses Unity's NetworkManagement, but it builds the spawning thing so it should work with some adaptations) https://www.youtube.com/watch?v=biOL7jCuV1g&list=PLPV2KyIb3jR5PhGqsO7G4PsbEC_Al-kPZ&index=8
just instead of respawn, make it spawn
You can't apply UNET principles for spawning to PUN2
UNET relies on the server to do the spawning
does UNET has matchmaking? like PUN2?
Not in the same way
i was thinking about just pressing ready or what ever and you are in a matchamaking
PUN2 is a completely relay based system, so it acts more like P2P in most ways
If you just want your players to not all spawn on top of one another, I would make X number of spawn points, index them, and use the PlayerId to pick which one to use.
You can revisit that later with something more complicated, but that will get you basic distribution at startup
can you send a tutorial or sm cuz i am new to networking
yes, that's what he explains in his video, he just goes into more detail about how to do it... but the basic concept works with Photon. Just use the spawning idea from there (called round robin) and network it using Photon
just make sure you're using the concept, not the networking part because Photon will be different than Unet
ye i know that
With that example the server is just going to keep track of the last used index.... for PUN2 you have to do int spawnToUse = ActorId % numberOfSpawnPoints
Sorry. I wasnt online @delicate kindle.
I was thinking on maybe implementing some multiplayer but have no experience. I was looking at this tutorial -> https://www.youtube.com/watch?v=MOLlHw0yn5g and it seems I can just use my current game and convert it? Does this mean unity has a built in networking system or? I would appreciate some more information. Thank you
In this tutorial I show you guys how to move around on a multiplayer server! I also show you how to make sure the cameras are in the right position, rotation, and if they are viewing the right player!
Project Files : https://www.dropbox.com/s/2ugnhn6z91upaql/Multiplayer Rac...
Do I need to download anything?
I also looked at other tutorial and they seem to use the same network manager stuff
Which multiplayer system/asset do you want to use?
UNet (deprecated)
Photon/PUN2?
Mirror?
and yes you need to download something
UNet
oh that's sad
I don't recommend to use UNet
because of the deprecated
yup
does photon work the same?
cause in the video it seemed pretty fast to implment 7 min
Photon / PUN2 works differently, but it should be easier to use.
ok thanks
no problem
I'm trying to set up a GameSparks Leader Board and I'm not sure how I can create an event / running total. I see that a new field for my leader board requires a running total, but the running total also requires an event. But I cant find where to create an event (I think its meant to be under configurator but I dont see it). Ty in advance!
This is what my dashboard looks like
Basically I don't know how to get to this screen.
@fierce niche Is this anything related to unity?
Ty for inquiring. It is a service amazon provides to game devs including unity. But I got reply elsewhere, again Ty anyway
Hi guys! Im doing a server and i need your help to make a live clock for different countrys! Can you help me pls? Im working so hard and i need your help! thank you!! (and sorry for my english but it isnt my native laguage) cheers!
@fierce niche do you have permission to access it?
it should show under configure > events
go to game overview and edit button make sure it's enabled under features and integrations
I installed photon bolt but can't seem to find bolt in the windows button
please help
oh nevermind sorry
HI i just check out Telepathy and read this Async Sockets: perform great in regular C# projects, but poorly when used in Unity. Could any one provide some more Informations? I know Telepathy and Mirror perfome great but this Telepathy uses two threads per connection. It can make heavy use of multi core processors. seems suspicious to me.
@weak lava So, async sockets do perform badly in Unity.
It has to do with the ancient implementation of them being used in Unity (from its Mono version), it's just not good.
But claiming that 'Telepathy' makes great use of multi core CPUs because it uses two threads per connection is just... well, eh... that's not how you do that.
If you are looking for something with works like old UNET, then yeah use Mirror. Otherwise look elsewhere.
Are there any Benchmark test out there ? I currently working on my own Framework and im using async. Its not only for unity but it also should work in Unity. So i have to decide, i guess ?
Completely depends on what you're trying to do, TCP vs UDP, How many connections you want to handle, packet rates, etc.
I've used Mirror and Telepathy in one project. It worked pretty good but it wasn't subjected to heavy traffic.
Inc today! https://www.youtube.com/watch?v=w6sn8bJiZ2g Multiplayer & Live Roadmap! : )
Join us on Wednesday, April 1 at 9 am PDT for the second installment of our 2020 roadmap, Unity 2020: Live Games.
We know you'll have a lot of questions about this roadmap, so we're hosting a Q&A on the Unity forum following the session. Product experts from across Unity wil...
atm im using TCP but maybe switch later to UDP, it should handle up to 20-30 ccu and a packet rate of about 30-40/sec.
@weak lava for 20-30 CCU it doesnt matter what you use
async will be fine
i'd probably just go with one thread and a Socket.Select poller for that low count
no point in mixing async or multiple threads into it
@graceful zephyr afaik, when i looked at decompiled code, in unity .Select allocates an array on every call
alright thanks @graceful zephyr
I'm pretty new to photon bolt and was wondering if all this text up top is gonna be there in the final build of the game
and if I need it
This is a tutorial project, of course you do not need these.
Try to read the docs and follow the tutorials
I read this in one of the photon forums No, you can press tab be default to disable it or turn it off in the Bolt settings. You can also implement BoltLog.IWriter and have it work as you want. I'm not sure what he means tho @gleaming prawn could you clarify?
You can turn it off in the bolt settings.
Networking middleware for Unity 3D and realtime multiplayer games and applications. Get started without having to know the details of networking or write any complex networking code.
where would that be
I don't see anything related to console
Networking middleware for Unity 3D and realtime multiplayer games and applications. Get started without having to know the details of networking or write any complex networking code.
thank you
Hi, i'm trying to build a network system for my multiplayer game, but i'm struggling in making the recv system...i've tried to follow the code from microsoft docs, in order to create an async socket recv operation...But with no success...when i use microsoft's code, my unity game freeze when trying to send/recv data...
Can anyone give me a snippet of code? To understand how should i implement the recv system with async sockets?
In Microsoft's docs, they say i have to create a StateObject class that holds the data/socket for the async calls
public class StateObject {
// Client socket.
public Socket workSocket = null;
// Size of receive buffer.
public const int BufferSize = 256;
// Receive buffer.
public byte[] buffer = new byte[BufferSize];
// Received data string.
public StringBuilder sb = new StringBuilder();
} ```
The Recv Method should look like this...```cs
private static void Receive(Socket client) {
try {
// Create the state object.
StateObject state = new StateObject();
state.workSocket = client;
// Begin receiving the data from the remote device.
client.BeginReceive( state.buffer, 0, StateObject.BufferSize, 0,
new AsyncCallback(ReceiveCallback), state);
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
} ```
And the Recv Callback should be this...cs private static void ReceiveCallback( IAsyncResult ar ) { try { // Retrieve the state object and the client socket // from the asynchronous state object. StateObject state = (StateObject) ar.AsyncState; Socket client = state.workSocket; // Read data from the remote device. int bytesRead = client.EndReceive(ar); if (bytesRead > 0) { // There might be more data, so store the data received so far. state.sb.Append(Encoding.ASCII.GetString(state.buffer,0,bytesRead)); // Get the rest of the data. client.BeginReceive(state.buffer,0,StateObject.BufferSize,0, new AsyncCallback(ReceiveCallback), state); } else { // All the data has arrived; put it in response. if (state.sb.Length > 1) { response = state.sb.ToString(); } // Signal that all bytes have been received. receiveDone.Set(); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
The problem is that receiveDone.WaitOne() makes the unity game freeze for some reason...
when trying to call Recv() in a Callback inside a Unity Component...
with StartCoroutine()
So...is there a better way of implementing this?
DM me if u have the time to help me ๐
yo guys im doin a simple setplayername
but i've got a problem
im doin a continue button
and an input field, if i write something on the input field the button needs to become interactable
@oblique charm please check #๐ปโcode-beginner , thank you https://discordapp.com/channels/489222168727519232/497874004401586176/695183761712742501
i really lost the hope...
@silent zinc Can't really see where receiveDone.WaitOne() is called, but blind guess would be that you're locking thread waiting for receive from socket.
Coroutines runs on mainthread afaik, so you're locking unity by that point.
@stray scroll I tried without blocking with WaitOne(), but i can't recv the response...
https://hatebin.com/ffsqyzkgib this is the full Client class
Hey everyone, I'm using SteamVR 2.5 & PUN 2.0 and I'm wondering if anyone ever encountered an issue where the master (and probably anyone else) opening the SteamVR dashboard would delay the sending of events or network view updates to other clients? I've already disabled SteamVR_Settings.instance.pauseGameWhenDashboardVisible So I'm not sure what's happening
Update: Seems the behaviour is inconsistent as in it's not doing it anymore... weird
@silent zinc so what is happening with this code you posted? Does it freeze? Where does it freeze?
@stray scroll It doesn't freeze, not anymore, since i deleted the WaitOne() and Set() parts...The problem is that it is inconsistent in the results... i mean, it doesn't receive messages from the server. The server is not the problem though...
I managed to solve that problem, now i recieve the response, but another problem occurred, since i don't know much about tcp...my response seems to have multiple messages in it... I'm struggling in sending a large base64 string over tcp...
I'm so confused, in python i could just use the asyncio library pre-built classes, to make an asynchronous client...in c# i have to make the protocol by myself...
How can i ensure that the entire message gets received correctly?
I don't know how, but somehow, now everything works fine...
@silent zinc I use a BufferedStream for my tcp. A way to ensure the whole message is received is to begin your messages with an integer representing the number of bytes in your message
Then it's a simple process: read the message size, read that many bytes, next message
I don't really know what chat to put this in but I really want to make a game but have know idea how to do, I don't know any code or anything. I have really good ideas for a game but I need somebody to help me, its a 3d battle royal, if you are interested, DM me.
If you haven't made a single player Unity game... do that first. Don't even consider making a multiplayer game as your first Unity project.
@sacred canopy
ok
Networking games is literally THE hardest and least supported part of Unity.
Starting there will make you want to quit game dev.
lol been there before
i dont know where to start
Just the Unity tutorials on their site is a good first step
ok
You need to first get familiar with the UI and coding in C# with monobehaviours
i dont know what any of that means lmao
how comprehensive is your design?
Use the regular dev channels for that, there is lots of support there and in like the GDL discord
@sacred canopy That's the point, you have to do the tutorials to even know where to start
ok i will look up one
Hey please, this is a Unity issue, i cannot make WWW requests in the WebGL build, it just freezes the game
I tried enabling CORS in htaccess config
but nop
cors issue usually indicate a problem with your server configuration
are you using https?
The server to which you are making the requests is probably not set up to accept them from whatever network you're on.
The server that i make the request to is HTTP, not https @slim ridge
I never used WebGL sorry
i can only guess that it makes a blocking network request. If there's some way to set a timeout that might help
You might also try your request in another application like Postman then resolve the differences between that and webgl
Trying another way instaead of WWW @slim ridge
with HttpWebRequest
and HttpWebResponse
classes from c#
Didn't work
This seems a fucking joke..
nah man, web requests aren't easy
Tried with "UnityWebRequest" class, with "WWW" class, and now with "HttpWebRequest" class, and all 3 doesnt work
in a webgl build
But no unity helpers help on it
thats what kills me
that is not my fault, its unities fault
it's probably not a unity problem them, i'd guess the problem is with the information in the request itsself or the server
the server is fine
i can make requests to it
with a Android build
or Windows build
workd pefectly, but with WebGL buil fail
great, then you have a place to start. Get a log of that successful android request and then compare it to the unsuccessful ones you're making with webgl
All those 3 classes works perfecty on all builds except on webgl xd
now this error displayed @slim ridge
what does browser javascript console say?
need to see the whole stacktrace
its just the same repeated
probably a unity bug then. What option do you use for "Enable Exceptions" ?
is it possible to spawn a Netcode ghost inside of a job or would I need to do that on the main thread?
@weak plinth Structural changes has to be done on the main thread, but can be recorded in a commandBuffer in a job. So what you would do is to create a commandBuffer from one of the sync points (i.e BeginSimulationSystemGroup, EndSimulation--, etc), feed it into your job, Instanciate your ghost there, where you can also do Set/Add components, which will then be played at next Sync point (when the group you created the commandBuffer from's Update is run).
@stray scroll thank you for that info. my current method is using the ECB to instantiate a prefab with a ghost authoring component on it that is then converted. however, I'm getting this error: InvalidOperationException: Could not find snapshot data Cube (1)SnapshotData, did you generate the ghost code?
do I need to pass the ghost collection in to the job somehow and reference it with a ghostId?
@weak plinth are you saying you're instantiating a gameObject and converting it?
https://hastebin.com/domewudure.cs I'm instantiating it via the commandbuffer here
Yeah ok, so only bad phrasing. So this is how I get the prefab to spawn
var prefabs = GetSingleton<GhostPrefabCollectionComponent>();
var serverPrefabs = EntityManager.GetBuffer<GhostPrefabBuffer>(prefabs.serverPrefabs);
m_crewPrefab = serverPrefabs[SpaceCraftGhostSerializerCollection.FindGhostType<CrewSnapshotData>()].Value;
To make it work you'll need to ofc have the prefab and updated it's list and generated the code
And also have the prefabs in the scene to create the Singleton entity, if you haven't click Update ghost list to get it in the list, then generate collection code.
alright I'll see if I can get that to work. thanks again
https://hastebin.com/ekaqefiyem.cs updated the code to reflect your suggestion. I've regenerated all ghosts and the collection code as well. still isn't quite working. debugger shows the entity but without any rendering components
@weak plinth Can't really tell by the picture, but generally try check the quick guide if there's something fundamentally you've missed. But for debugging, go the entity debugger; check in both client and server world if the entity exist (not only the prefab but the actually spawned entity). There is no default rendering in server world, to render in client world with entities you'll need Hybrid Rendering package.
trying to make Photon load a scene with "PhotonNetwork.LoadLevel(1);" but it wont load
the scene has the right index and there are no errors shown
Is there any info/tips about latency optimization for Unity.Networking.Transport?
For example, I just do not want to wait whole frame and for the next one to start just to send my packets queued at the beginning.
Ideally I would like to know, if there is any possbility to split receive/send jobs.
Is someone able to assist me real quick with some Photon PUN?
So I have two RPC methods that I want to sync across all clients, however only one of the methods work
here is the code I use
so my test() method is called on my player.cs script (attached to the player), but syncID() is not
either I'm not sending the RPC from my gamemaster.cs, or for some reason my player.cs doesn't accept the call
@whole granite I don't really see the problem? Just put your send in send jobs?
Won't NetworkDriver.Concurrent.EndSend(DataStreamWriter) send it right away?
I don't think so. As it has internal send queue.
Oh, actually it will.
Thanks @stray scroll
It calls return NativeBindings.network_sendmsg(*(long*)userData, &iov, 1, ref *(network_address*)addr.data, ref errorcode);
yeah
any help?
@cedar cloak calling it on master client?
yes
I'm really getting mad cause the script its only few lines and should work correctly
Don't get mad, get data ๐
can anyone help with my problem?
You have tried a basic test scene outside of your project to make sure you are using the method correctly? @cedar cloak
I don't use RPCs so that part of PUN I can't speak to... but abusing buffered RPCs is asking for trouble - I know that.
@civic stream
yeah and u call it in Update() that's probably overflowing some buffer somewhere
ah
I see
so should I just use all instead of bufferedall?
or can I clear the buffer?
also you access the photonview three different ways xD
Clearing the buffer would defeat the point of the buffer no?
People typically use buffer to make late joiners initialize correctly no?
yeah
there must be something to tell you that an RPC has completed successfully or errored?
yeah
its not meant to be spammed, and the docs I think warn against that.
I put a print() to signify if the RPC method has been called
Just RPC normally
wdym
You have tried a basic test scene outside of your project to make sure you are using the method correctly? @cedar cloak
@jade glacier yes
the 2 scenes are basically empty
dunno then. If its included in the BuildScene list, it should be getting indexed. They all have unique names i assume?
sure
can you load the scene programmatically without photon?
can you load the scene programmatically without photon?
@slim ridge you mean with loadscene?
yeah
tried SceneManager.LoadScene(1) and doesnt work too .-.
ok then you know it's probably an issue with the scene and not photon
Then its not a networking issue, its just an issue
right
Best to hit up the regular unity help channels for that kind of thing
your are restricting yourself on help quite a bit by trying to sort that here
seems like some issue regarding the method
in some way OnJoinedRoom() is not working
You need to show code if you want any feedback on where you are going wrong
Otherwise all we can do is nod our heads in agreement that yes you have a bug
here's the code
please save my life
The script is attached to and Empity Obj in the supposed Main Menu (0) and should take to the Game (1)
I never used photon so i dont think i can help
If you can't even load the scene with scenemanager perhaps you should ask in general-code
either use hatebin.com or paste your code here using ```cs //yourcode ```
its not about the scene loading itself
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class Launcher : MonoBehaviourPunCallbacks
{
public void Awake()
{
PhotonNetwork.AutomaticallySyncScene = true;
Connect();
}
public override void OnConnectedToMaster()
{
Debug.Log("CONNECTED");
Join();
base.OnConnectedToMaster();
}
public override void OnJoinedRoom()
{
StartGame();
base.OnJoinedRoom();
}
public override void OnJoinRoomFailed(short returnCode, string message)
{
Create();
base.OnJoinRoomFailed(returnCode, message);
}
public void Connect()
{
Debug.Log("Trying to connect...");
PhotonNetwork.GameVersion = "0.0.0";
PhotonNetwork.ConnectUsingSettings();
}
public void Join()
{
PhotonNetwork.JoinRandomRoom();
}
public void Create()
{
PhotonNetwork.CreateRoom("");
}
public void StartGame()
{
if(PhotonNetwork.CurrentRoom.PlayerCount == 1)
{
PhotonNetwork.LoadLevel(1);
}
}
}
The problem is the OnJoinRoom whitch doest work, tried to put a DebugLog in there and doesnt appear
oh okay
JoinRandomRoom fails if no room is available
perhaps you need to use JoinOrCreateRoom
oh i see
your joinraondomroom fails so you make a room but dont try to join it
PhotonNetwork.CreateRoom("") -> PhotonNetwork.JoinOrCreateRoom("") ?
@cedar cloak Have you tried the built in demo setup tool to see if that works?
PhotonNetwork.CreateRoom("")->PhotonNetwork.JoinOrCreateRoom("")?
@slim ridge doesnt work ๐
@burnt axle wym witht that?
I think a room needs a name, not an empty string
Try to use a debugger in your texteditor/IDE
no errors
Follow the trail and see what happens
what else should I check?
Set a breakpoint on the join statements, and see what photon does internally
You can also check to see if the pun framework is working in general by trying out a demo: unity editor > window > photon unity networking > Configure demos (built setup)
if(PhotonNetwork.CurrentRoom.PlayerCount == 1) what is that check trying to achieve?
Second player to join a room is going to fail that test
yes because first player should create the level while the others should sync to that already created one
so I put a DebugLog on every functiona and it just does the Connect() and Join()
no OnJoinRoomFailed ?
lol this why i dont use photon
You are trying to create a room right? And it fails while not calling OnCreatedRoom, OnJoinedRoom or OnCreateRoomFailed?
so basically it start by searching a room, if the players doesnt find any available it should create a new one
You probably mean to have the MasterClient do the scene changes, rather than just playercount == 1. Likely means the same but you are opening yourself for edge cases.
I just tested a simple script for the same purposes you are trying to do, and it works fine here
I just tested a simple script for the same purposes you are trying to do, and it works fine here
@burnt axle using basically same as mine?
But you should really test the Demo first, just to make sure that Photon works in general
@cedar cloak Yes, just a basic script for connecting and creating/joining rooms
What @burnt axle said for all networking, avoid complexity or too many moving parts at once.
My life as an asset dev is people dumbing 20 assets into a project, and copy pasting a bunch of stuff from 5 different tutorials and then emailing me with "Your asset isn't working"
Networking is fragile as F
i just followed 1 long tutorial to reach this point, I know that copy bunch of random asset will surelly fuck up the project
The tutorials are to show you workflow btw... NOT for cutting and pasting code from
I wouldn't start with a tutorial (they are all questionable at best anyway)
and its super strange and its working on him and not on me, other people in comments got this issue too but noone replied yet
yeah i recommend using .Net and writing your own protocol.
Do the tutorial... then throw it out.
If its in the comments to that tutorial, then sounds like the tutorial has a bug
Do the tutorial... then throw it out.
@jade glacier I will but i would to complete it first to understand what happend, for now I knew 100% about the not Photon related code, but since the networking part is new for me at the beginnig would prefer to follow instruction of someone whos already into it
Which again, is why I would not copy pasta from any networking tutorials. They are notoriously TERRIBLE
you are stuck ON the tutorial?
as in the tutorial isn't working as advertized?
If you are following the tutorial and its not working, then that tutorial may have a bug in the code the are recommending. That or maybe a step got missed. Hard to say.
@cedar cloak Just read the guides from Photon itself, they are pretty good and gets you going right away. Tutorials on Youtube might be good at times but they can also be outdated so make sure they are up to date first. But i would recommend reading the guides and docs from Photon itself, as its more updated and accurate.
i hate scrubbing youtube videos for that one nugget of information you need xD
always prefer text tutorials with images
Video tutorials should ONLY be used for initial workflow overviews. They are terrible otherwise.
@cedar cloak Try this simple script: https://pastebin.com/4xhVkv7x
Attach it to a empty gameobject, and click on the GUI buttons to connect, join a lobby and then create a room
You might have to wait ~1s before clicking the "join lobby" button, because Photon needs to connect to the cloud properly first
that might be his problem right there
That is a design flaw in that tutorial
LOL asking the user to not push buttons too fast.... good design.
That is like the first online shopping stores asking users to not click "Buy" multiple times if the site isn't responding
The callbacks handle all of that timing, so that shouldn't be a problem
The prototyping components built in can be extended
Of course you use callbacks in a game ready script lol, i just put something quick together just to see if it connects at all
any idea on how to make custom registration and login
You need a database and a GUI with scripts attached that threates the user data.
have server n database setup but not sure how to setup the code for registration n login
- make the GUI that can recieve user input
- threat the user input (validation and sanitazion and other checks)
- save data
- prompt user with a status message (successfull/fail)
I dont think anybody here will show you step by step with code on how to set it up, you need to google this. What we can help you with is specific questions
any idea where i can get much more info on this
you mean like sending http requests?
i have api where i want to send and receive details from
http request it is
googled for this but didn't find much info
What kind of API?
sorry url
Yo Guys! This is a 3 part Series On how you can make a Login / Registration Menu For a Game, I hope you guys enjoy, if you did It would be awesome if you could smash the like button!!, Lets me know you guys are loving it.
This is the Download for the project i showed in the v...
I'm not crazy, UNET HLAPI didn't vanish from Unity last night or something, right? I'm just having some big issues with my packages if suddenly Visual Studio can't find any of the references, right?
@delicate shard Seems like the tutorial goes over everything except the HTTP requests, but you can follow the tutorial and extend it with your own HTTP requests. C# language already has HTTP classes and such
its been removed from Unity for a while. Newer versions you have to specifically add it to your project.
but I didn't upgrade the version of Unity between yesterday and today
@blissful fractal I hope you are aware of that UNET has been deprecated a long time ago and its probably loosing support really soon. Time to switch if you are using a production game ๐
they wouldn't slice it out of versions that had it
oh I know
I'm being an idiot in that regard
I WAS hoping to ride it out while I tinker until the new unity solution is out and well documented
@burnt axle yeah that's what i was looking at that tutorial got nothing on http request, btw thanks for the share ๐
If your project was already making use of it, I think it stays in as a package... but I have no real experience with trying to work with it past 2017 @blissful fractal
lol
yeah
ok, I'm pretty sure dropbox just jacked the packages
but I wanted to make sure
I guess I'll go ahead and just switch to photon
The new Unity multiplayer framework is already out
"out"
Looks like its only avaible for paying customers?
Yeah, pretty fresh
or use .Net and write your own protocol ๐
- Yeah I usually need my hand held a bunch on networking, so jumping in to it while it's still so fresh is a recipe for disaster.
- if I wrote my own protocol, I might break the internet
what's more fun than breaking the internet?
fair enough
I'm still kiddy pool, maybe I'll get there in a bit
I'm not TERRIBLY intimidated by writing my own, but I just think it would be a waste of everyone's time until I feel more comfortable with networking in general
there are some advantages
- you will understand whats happening end-to-end and have complete control
- you dont have to do unnecessary things to fit within the confines of whatever prebuilt solution you use
like with photon people have trouble finishing the tutorial cause there are a lot of parts they assume will "just work"
but if you want to get your feet wet, look up google protocol buffers ๐
There is nothing wrong with using complete or partial stacks of existing net libs when getting started into networking. Networking involves about 5 layers of API, and learning any or all of them has value.
Unity -> photon -> .net -> tcp/ip -> os
There are the aspects new net devs don't want to write. Like the layer above the transport is the objectID/conduit layer for identifying objects, and their owners and dealing with directing messages to the right destination objects.
Then there can be a layer above that that deals with tick/simulation and timings involved in that.
And there can be layers above that that have premade components and codegen to actually make for codeless UX.
all that sounds interesting for sure, just a matter of where to start
I'll do some googling and see where I land!
โฅ๏ธ
Just start with the standard libs and tutorials.
Once you get comfortable with those, higher and lower concepts will have more meaning.
You can read up on sites like gafferongames.com and such
๐
to start learning about the concepts, but applying them is still a long way out.
yeah for sure
i'm building a physics server/client with deterministic lockstep it's really difficult
I'm hoping only for 2d games
Hi, I'm just starting to learn tools for working with the network. There is a task - it is necessary to initiate broadcast push notifications to all available devices with the application. Something like an emergency alert that is triggered on the server. Is it possible to implement using the functionality of Unity libraries? If so, please tell me which side to look for?
this is actually handled at the device OS level. Android and iOS have their own methods of pushing notifications
You'll have to go through the nightmare of setting those up in your app and in your server
Thank you, so I have to delve into the native functionality of OS. Bad news.
@jagged flame you should probably just go with a push notifications wrapper service
does a server need a port number from the client to know where to send the data?
or is the only neccesity for a port number when a client tries to send data to a server
@toxic lintel when a client connects to a server using tcp/ip on a known port, the server has a two-way connection
alright
is that helpful?
wrapper services can get expensive beware
@jagged flame if you're only targeting android you probably want to just use what google provides through firebase
yea i think that means yes
right
also ip adress points to a specific machine right
@toxic lintel what's your objective? to give someone a text box, in their game, for which "host" to connect to?
Found api for a similar functionality - plexure. Maybe itโs not so difficult. I will continue to explore the issue. In general, in order for the server to know about the client, you need to communicate regularly, which is not good. Or somehow there should be a list of clients on the server
that only really works on local networking (LAN) in practice
no I am trying to learn more about networking in general
am i going in the right direction with socket programming
yeah
@jagged flame don't worry my dude i can read russian at a 3rd grade level ๐ i like urban airship (now airship)
the server does maintain notification lists, yes
that's all the right idea
))
thanks for the help btw
@jagged flame the external services do a good job of knowing like, how many times to ask the device for notification settings, etc.
they keep an updated list
firebase looks like the simple box solution ( IOS: https://firebase.google.com/docs/cloud-messaging/ios/device-group, Android: https://firebase.google.com/docs/cloud-messaging/android/device-group )
thanks for the discussion, I hope that there will be no bureaucratic problems using external services\
Yes thatโll be a super good one for Android
can anyone help me? i'm new to unity multiplayer and the character doesn't spawn.
not without more details
i have no idea what that is
ok I'm back
same issue
this time I'll just paste my entire code
if someone can tell me why this isn't working I'd give you a high five
assume all variables are properly declared
You would need to say what you mean by "isn't working" specifically, and point out what part of the existing code is where you find it is breaking when running debugging
If you aren't good at debugging yet, I would STRONGLY encourage not trying to develop a multiple player game. They are considerably harder to debug than a typical single player unity game.
ok
so
I managed to get one RPC call working
a really simple one
it just sends a float which increases in size
my player.cs script was able to receive the RPC and print out the updated variable
but for some reason, even if I disable my test RPC method
my new one just doesn't work
there's no difference other than I'm sending an int rather than a float
can you remove all pronouns from that question though?
hard to say without know what "my test RPC method" means in context of the various connections and such.
its also not overflowing the buffer because the PV.RPC is called once
its just a simple RPC method
[PunRPC]
void RPCFunction(float syncVar)
{
SyncVariable = syncVar;
Debug.LogError("SyncVar changed! " + SyncVariable);
}
So what is "the new one" ?
RPCSyncColours()
What are the arguments in that and you set it up in the PUN settings as a known RPC type or whatever is needed to be done there?
I don't actually use RPCs in PUN, so I don't know what is involved.
But I know it doesn't weave, so something has to be wiring up the RPCs
its not weaving and its not codegen, so I assume reflection?
Looks like just the declaration is all that is needed, so I assume its reflecting behind the scenes and producing a RaiseEvent(yourArgsAsBoxedObjects[])
So what does your RPCSyncColours() look like in code?
its in the pastebin
I'll paste it again
[PunRPC]
void RPCSyncColours(int ID)
{
print("Changed colours");
}
this is how it looks on my gamemanager.cs
[PunRPC]
public void RPCSyncColours(int ID)
{
print("added colour " + ID);
PhotonView colour = PhotonView.Find(ID);
colour.gameObject.transform.parent = this.gameObject.transform; //set colour to this object as child
}
I believe int is a valid argument primitive
yup, int is legal
Global cross platform multiplayer game backend as a service (SaaS, Cloud) for synchronous and asynchronous games and applications. SDKs are available for android, iOS, .NET., Mac OS, Unity 3D, Windows, Unreal Engine, HTML5 and others.
You have the same named method in two places?
yes
I would avoid that
in two different scripts
without knowing what is behind the scenes with hashing, that is not a risk you should be taking while debugging
If you call the RPC inside of the class it is in, does it work?
attribute based syncvars and rpcs are typically a minefield of things that can break them.
its not given the [SyncVar] attribute
its just a normal float
unfortunate naming on my part
SyncVar?
yes
I just missed the lane change, we were debugging your rpc
also the RPCSyncColours() method isn't being called in the gamemanger.cs script
yes
There is no syncvar in PUN is there?
srry unfortunate naming
So if you call the seemingly broken rpc from inside of its own class does it work?
nope
[PunRPC]
void RPCSyncColours(int ID)
{
print("Changed colours");
}
that print statement isn't called
PV.RPC("RPCSyncColours", RpcTarget.Others, playerColour.GetComponent<PhotonView>().ViewID); //pass ID
That call you are making, you are indicating the correct PV? And this would also indicate that you should not be using the same name in two places
I'm not
private void Start()
{
PV = GetComponent<PhotonView>(); //create inital PhotonView object to reference later
}
I only have this
that should be the right PV. Having identical names would definitely break this.
doing "this.photonView.RPC" and "photonView.RPC" doesn't work either
since no reference to the component is given, there is no way the PV would know which you mean... so it doesn't even care. There is one RPC per string name
this has no value in this context
but even after disabling the other RPC call, it still doesn't work
you changed the name to make sure there are no repeats of the same spelling?
I declared "private photonView PV;" at the beginning
I'll try changing to something completely random
but they are unique
The method is definitely being called?
on the calling side of the RPC?
A debug there would be good to make sure its not some other bug
I wouldn't use stops while networking... that will just break things completely
I tend to stick with Debug.LogError
So the PV.RPC() is getting called?
but I've had an issue where unity would freeze at some networking call before
I'm assuming so
I would check that
how do I check?
otherwise you may be debugging nothing
if the method its trying to reach isn't reached?
put a debug in front of it and make sure control is getting there
Debug.LogError every possible step of the way
this kind of guessing will take hours at this rate
Seed the entire path of operations you expect to happen on both sides of the network
it is
Yeah, let's not do that. Debug the crap out of it.
So you can isolate exactly where code stops doing what you expect
You are certain then control is getting to that call.
You have put a debug right before it and it indicates control getting there.
Not sure why print
WAIT HOLD THE FUCK UP
I THOUGHT IT DID
I swear it made it to the call
looking over it looks like it stopped right after I did some list indexing
With networking this will happen a LOT
assume nothing. Seed debugs all over the place. It often isn't broken where you think it is.
I'm actually face palming
the entire if statement
that is enclosing the rpc call
isn't actually running
it assumed that the player would add itself to the playerlist upon spawning, but in order to spawn it had to wait for the RPC call
which was in the if statement
Can somebody explain me how to sync a lineRenderer with Photon ?
With rpcs with vanilla pun. Or you can try SNS and use Syncvars.
Thanks, I have to read some stuff about it first :)
It actually worked thank you man ! Didnt expect its that simple
Has anyone built to WebGL on PUN Classic 1.102? NetworkingPeer:818 is trying to set SocketWebTcp.SerializationProtocol, which is inaccessible.
MIRROR NETWORKING 11.4.2 IS LIVE ON THE ASSET STORE
Download: https://assetstore.unity.com/packages/tools/network/mirror-129321
ChangeLog: https://mirror-networking.com/docs/General/ChangeLog.html
I'm using Photon PUN 2, and I'm having trouble figuring out how to refresh my lobby on will!
So, basically, I've had networking set up for a while: Now, I've recently set up a lobby system to give my game more control over which room is joined. When I join the master server, I use PhotonNetwork.JoinLobby(). Then, when it's connected, in my Lobby Script the OnRoomListUpdate() callback is called, which caches the room listing. This works great, and I have a stored record of the names of rooms and number of players in them! I then use that data to choose and join a specific room
Now I have an issue though: While a player is in-game and inside of the Room they joined, I want to still refresh and get the updated lobby's room list, so they can see other rooms available while in-game. The issue is... OnRoomListUpdate() never hits again. I can't figure out how to force a refresh when I need it... or get any refreshed data at all after the first time!
For example, say there is a situation where there are no rooms yet. A player connects to MasterClient, and joins the lobby: OnRoomListUpdate() is called, and reports that there are 0 rooms at the moment, which is accurate! So, the player creates and joins a room. Now, in theory, it should report that there is 1 room, since we just created one... but the OnRoomListUpdate() callback never triggers again, and I can't figure out how to force refresh that listing in any way.
Does the lobby stop working once a player joins a room? I've tried a bunch of things, including even leaving and re-joining the lobby, which has zero effect (doing that won't even trigger the OnLeftLobby() callback, which is weird). I want to keep accessing the lobby and have it refresh OnRoomListUpdate() while the player is in-game, how do I do this? Is there something I'm missing?
I've done some more testing, and it seems that as soon as I create/join a room, "PhotonNetwork.LeaveLobby();" stops working, and will not call the callback "OnLeftLobby()".
TL;DR: It seems that the Photon PUN lobby just stops working as soon as a room is created/joined. I'm... uh, not really sure why it's made so we can't keep accessing the lobby info after we join a room... ๐
Does anyone know any sort of work-around? All I want to do, is (After the player has already joined/created a room), be able to get a list of all available rooms, with the room names and number of people inside, so I can know which to join. Does anyone have any ideas? Thanks so much, I know this is a long shot!
I never use lobby, but when you join a room you are connecting to a different server. The game server and matchmaking server are two separate things is my understanding.
Not sure if there is any easy out soon hacky way to create a matchmaking server connection while in a game, but I don't it.
Yeah @jade glacier , I'm super confused why we can't just see the listing of all rooms after we joined a room... ๐ Thanks for the response!
You could cache it. But it's literally info you get while connected to a different server. When you join a game that connection is dropped to the matchmaking server, and you connect to the room server.
There might be some way to poll the matching server other than connecting, but I have heard nothing about that.
Drat, caching isn't an option since I want live updates on the statuses of rooms... I want players to be able to see if there are other rooms with more people in them, and select to join those rooms if they want
@stiff ridge might know a way. But he will be offline for the weekend.
If anyone else knows a way (Photon PUN) I could get an updated list of rooms while already inside a room... Please let me know! Thanks!
That is not possible for the reason emotitron posted
Photon does not offer a specialized matchmaking solution.
If you want to create custom matchmaking stuff, you can use playfab of others and use photon for the realtime part
@nimble eagle you could tell all the players when a new room has been created
and have them update their own list of rooms
have you considered running another "client" in another thread that just joins the matchmaking server when you enter a room?
then you just keep swapping clients when they leave/enter rooms
Thanks, those are good suggestions! I realized I could just put room joining before the player enters a room without too much difficulty, it still solves the original issue I needed to solve; Thanks for everyone's help!
Is it possible to get the "PhotonNetwork.LocalPlayer.UserId" from another client via the Raycasthit ?
I'd make sure the UserId is a property of the object being hit
The photon view keeps that yes
hit.transform.gameObjectis that what you're looking for?
I actually save the ID in the start Method of the Object ; clientID = PhotonNetwork.LocalPlayer.UserId;
then i save the ID of the Player that got hit by the ID: hookedPlayerID = hit.transform.GetComponent<AdvancedWalkerController>().GetClientID();
Then I call a RPC : photonView.RPC("RPC_AddForceToPlayer", RpcTarget.All, _hookObjectVelocity, hookedPlayerID);
and in the RPC I compare the two IDยดs : if (string.Compare(clientID, GetClientID())== 0){ //Do something};
but it seems to send the wrong ID ... the hookedPlayerID is the ID of the Player who shoots the raycast and not the Player who got hit... Any suggestions ? :)
I can't comment on that. Your GetCliemtId() isn't pun code and I can't see where it is getting its value.
GetClientID() just returns the saved clientID from the Start Method
Too much unseen code. But if you shoot someone and want that someone's connection I'd, you get that from the objects pv.
What is client Id?
That isn't a pun term
And start is a risky place for net code. That should all happen in OnJoinedRoom
Unless you are certain that object will be spawned only while already in a room
Till now I am certain, but I will apply your tipps, and try to get it to work with the photonView stuff, Thanks man your great !
What do you mean with assumptions ?
You are assuming you are getting values, or cached values are correct