#archived-networking
1 messages · Page 104 of 1
Do you know what a namespace is?
yes
I have no idea if that is how you install MLAPI, but if the rest of MLAPI works, just using the correct namespace for NetworkBehaviour
work!
thanks!
another error
if(!NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer)
Object refence no set instance of an object
Is there a NetworkManager in your scene?
No
yes, no!
You are trying to access a NetworkManager, but you don't have one?
Are you totally beginner at Unity and C#?
no
Ok well, follow the video properly
Because if you don't have a NetworkManager, you either missed a step, or haven't got to a step
Either way, you cannot access what doesn't exist, null reference
No
I have not missed anything
If NetworkManager.Singleton is giving you a NRE, you have missed something, don't try and argue the toss
This Unity Multiplayer tutorial will teach you all about the new official Unity multiplayer solution and how to get it set up quickly in your own project!
Multiplayer Course: https://www.udemy.com/course/unity-multiplayer/
----------------...
Do you have an object with a NetworkManager?
Answer my question
You do know this is a video series?
This was the installation guide, find the next video
so how to add this network manager
It's a component
щл
But find a different series if you don't like this one
Give it a go
i add network object component
Did I say NetworkObject or NetworkManager?
oh sorry
work
button
host
server
and client
but when i click on them nothing happens
Network transport
= None
but should i do
in video
its defined
Well there's only two options
Tutorial that explains creating a project, installing the MLAPI package, and creating the basic components for your first networked game.
workkk
!!!
i click to the UNET
transport
and this work
lol
it remains to add a network prefab
but how?
You should follow the tutorial I linked
Lel
How are you so patient man
Respect
It's completely dependent on my mood at a given time, my friends say I usually have a short fuse
So you must be in very good mood today
Does anyone know how to test a networked game using unity itself without building the project
https://github.com/VeriorPies/ParrelSync Is something I see used often for that
You have two Editors open, and one is mirrored to the other
So for Pun2 I added a OnOwnerChange to a script, and a targetcallback in the awake and destroy but it still doesn't work
Is there something else I need to have it receive the event for when the objects owner changes?
Could it be I'm not inheriting from the right class?
@cunning sluice Put the script up somewhere. The target callback addition stuff should do what inheriting used to.
using Photon.Pun;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
public class XRGrabNetworkInteractable : XRGrabInteractable, IOnPhotonViewOwnerChange
{
private PhotonView photonView;
private Rigidbody rBody;
// Start is called before the first frame update
void Start()
{
photonView = GetComponent<PhotonView>();
rBody = GetComponent<Rigidbody>();
}
protected override void Awake()
{
PhotonNetwork.AddCallbackTarget(this);
base.Awake();
}
protected override void OnDestroy()
{
PhotonNetwork.RemoveCallbackTarget(this);
base.OnDestroy();
}
protected override void OnSelectEntered(XRBaseInteractor interactor)
{
photonView.RequestOwnership();
rBody.isKinematic = true;
gameObject.transform.parent = interactor.transform;
if(!photonView.IsMine)
{
}
base.OnSelectEntered(interactor);
}
protected override void OnSelectExited(XRBaseInteractor interactor)
{
if(photonView.IsMine)
{
rBody.isKinematic = false;
gameObject.transform.parent = null;
base.OnSelectExited(interactor);
}
}
public void OnOwnerChange(Player newOwner, Player previousOwner)
{
print("Changed Owner");
if (!photonView.IsMine)
{
Drop();
print("This is not mine");
if (!rBody.isKinematic)
rBody.isKinematic = true;
}
}
}
Is it because I don't have the monobehaviourpun?
I'm about to try making a separate script inheriting from that
@cunning sluice Looks like AddCallbackTarget might not cover that interface
Ah yes, that's a PhotonView callback, so instead of registering to PhotonNetwork, you register to the photonView instance
You might be looking for IPunOwnershipCallbacks?
Though I think the photonview specific one fits your usecase better
so it should work if I use these? MonoBehaviourPunCallbacks, IPunOwnershipCallbacks
I wouldn't change that stuff, just change the CallbackTarget lines
Some callbacks are photonview specific, and some are.. network specific.
PhotonView callbacks should be added to the photonView instance, and not to PhotonNetwork
All classes implementing any PhotonView callbacks interfaces except IPunObservable must be registered and unregistered. Call photonView.AddCallbackTarget(this) and photonView.RemoveCallbackTarget(this).
oh I see, and I was calling PhotonNetwork and not the photonView itself
so if I switch that up, it should receive the event correctly?
Right
ahhhhh
okay hopefully that works lol
this thing has been a pain in the butt since it's hard to test by myself
thank you
hello guys
is there any production ready solution?
or i should use something like mirror or photon?
MLAPI being at 0.1.0 implies that they don't think it's production ready.
@spring crane do unity have any other solution except MLAPI?
High level networking solutions for Monobehaviour, no.
I think they have a transport layer of some sort, but no idea what is the state of that, and I imagine you want something a bit more than just a transport layer
ECS has a networking solution of some kind, but no idea what the state of that is and you probably aren't going to be using ECS.
yep, i'm coming from another engine, and having hard time struggling to pick the right networking solution
Both MLAPI and the Unity Transport Package are still experimental.
cuz i don't wanna just play around with it, i come to unity to remake my 2D game
so what is the top/best solution as for now?
Well there are a lot of different frameworks that work fine
<#archived-networking message> for a misc collection of networking framework names
photon is pretty popular, and so is mirror
I think microsoft also has something
and epic games
what do u mean by microsoft and epic? they have networking solution for unity?
yeah I believe so, I looked into it at one point
let me grab the links
They likely have backend services and transport layers, I doubt they have high level frameworks for Unity
and even though it's name brand
I don't believe they have as many resources as some of the other options
like mirror and photon
idk, danny knows way more than me on this stuff
I just started 2 weeks ago 
ok, thanks much
on multiplayer experiences anyways
unity should make things more clearly-easier for beginners
the downside of that other game engine (i think i can't tell his name), is that don't care about 2D games
and the downside of unity is that don't care about beginners
most of my time is wasting to pick the right tools, instead of learning unity-coding-designing game
Mentioning Unity's competition by name is fine 😄
the problem with photon is CCU payment, and my game would be F2P and asking for support devs DLC
What would you recommend we do to make it more clear to you?
@verbal lodgeif unity can't give us a native networking solution, at least setup an official page where we can read about top/best current solutions and read those pros-cons
or something like it
Have you seen this: https://blog.unity.com/technology/choosing-the-right-netcode-for-your-game
ah, that's good, pls place it upfront of the unity page
or somewhere which we can find it more easily
What would be the best way to just send and receive data over two devices in Unity? I don't need replication or anything, just support for transferring data like audio files, etc
easy mode: devices are on the same network
Either use the phone built in share function or try to use serialport, for example.
Lol, following that decision-making tree I should use MLAPI or Mirror, but using Photon Pun2 for small coop based game and I started thinking about switching the netcode API some time ago and wondering if Mirror wouldn't be better...
@river meteor I wouldn't worry about it. That guide is not a replacement for your own evaluation.
yeah I know but Mirror is free
I dont know why but Photon Pun is not even listed in that decision making tree xD
I am also still worried about photon pun limitations for ex. number of declared RPC shortcuts
My project is at early stage so changing network API will not be much work
hello, I have a basic question about PUN and RPC, when My first player spawn in the map, I have header with healthBar + nickName, when the scond player login, this player can't see the nickname and the Healthbar not updated for the other player too. Can I have advise for understand this mistake ? 🙂
so any player dont see their correct values for nickname and health?
they can see their own information, not other one
okey
same for the healthbar update
You must sync these values and it is easy af
just inherit IPunObservable interface in your player class
then implkement the interface
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.IsWriting) // Here you are sending values to other clients. REMEMBER, all values must be readen then in the SAME OREDER as WRITTEN
{
stream.SendNext(nicknameValue);
stream.SendNext(healthValue);
}
else if (stream.IsReading)
{
this.nicknameValue = (string)stream.ReceiveNext();
this.healthValue = (int)stream.ReceiveNext(); // you must cast it to type which your values uses, so I dont know if your health is int or float or double...
}
}```
and thats it
it should work
ok I read and try to understand this code; thanks so much
If you will have any problem ping me I will try to help best I can
I wouldn't consider creating and hosting your own servers exactly "free"
so what is paid in mirror?
The opportunity cost of spending your time figuring out the replacements for PUNs matchmaking and relay server infra, not to mention that you still need to host these somewhere
In small coop game listen server is the best solution I think... in this case still I need matchmaking and relay server infrastructure?
Odds are your players are not going to open their own ports
It can also be nice to have rooms players can discover instead of passing IP addresses around
oh yeah I see the problem now
honestly could just use pun2
they have room sizes of 20 for free
I believe among us uses it
I dont understand this pricing system at all
Among Us doesn't use PUN specifically, just something very similar to it
do pun2 allow for creating server scripts & networking? , creating master server for authoritative and player profile system?
or instead of aut match making, let players to create custom lobby, add/invite friend
as mirror give u full control over client and server, i'm sure i can create such these things with mirror, but running and managing relay server still need some works, which in pun2 u don't need to worry about
i don't know much about pun2, so if anyone tell me some of it`s strength over mirror, the only thing that i know is about auto managing relay servers
In that case you might just grab realtime and their server instead of trying to hack PUN. I would ask in the Photon server to see what they suggest.
that's mean more payment, while mirror give it for free
If you want authority in mirror you also need to pay for hosting unity servers. That won’t be cheap
So free is not really free
nop
u can do it with relay servers
and anyway we need a master server
on mirror there isn't any force to use unity servers
but on photon, u have to use photon servers
I really don't understand Why but when my second client instantiate the player, he instantiate the player + the player already in the game
Hey guys, what networking solutions are you using? I don't need a 1:1 unet, infact I would like a more performance-optimized solution. I did have a go at Mirror not long ago, but it's unsatisfactory
To be more clear, I don't need RPC functionality, ideally I would like a more direct approach
I've had a look at ENet and it seems very promising and I am just mostly wondering if anyone else has had a good experience using it?
And also if there are other libraries that can perform like this
With Mirror, how do you send microphone input over the network to be heard by other players?
I think I have aproblem with this code:playerObj.GetComponent<PhotonView>().RPC("Initialize", RpcTarget.AllViaServer, PhotonNetwork.LocalPlayer);
@atomic sierrawhat is ur problem with mirror? cuz u are looking for a p2p networking & NAT solution? (trying to avoid dedicated server)
or ur problem with mirror is something else?
and about Enet, as far as i know, none of unity solution are production ready, and there isn't any guaranteed to work well w/o any bug, and if u found a critical, u can't do anything
Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: Joining). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
Photon error
I Instantiate the player using its prefab through the line: "PhotonNetwork.Instantiate(player_prefab, t_spawn.position, t_spawn.rotation);"
Its in a empty gameobject in the map scene
My problem is my public PlayerMain[] playerMain; is added well with my first player, but it doesn't works with the second... someone know why please ?
PlayersInGame's value also 1 with 2 clients
I don't see anywhere in that code where you add anything to that array
Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: Joining). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
Help me please
Photon error
Network operations are not instant. As the error says, the client needs to be in certain state to do certain things
Set timer?
Or wait for those mentioned callbacks
Looks up those callback names for PUN documentation
what method to indicate when you can enter the room
i mean something like public override void OnCreateRoom()
Either Joined or ConnectedToMaster by the looks of it
could you tell me how override void onjoinedlobby works
You should be able to find the info by looking it up. Could also study the samples provided with PUN
They have pretty extensive lobby samples
then send please link for pun 2 free documentation
I am using the free version of the pun, the pun version documentation may differ from the free version
It doesn't
override void ConnectedToMaster doesnt exist
Hello so i am making a amultiplayer game and trying to show rooms in my find room fuction using prefabs that works but when clicking the room to join it i get this error
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Photon.Realtime;
public class RoomListItem : MonoBehaviour
{
[SerializeField] TMP_Text text;
public RoomInfo info;
public void SetUp(RoomInfo _info)
{
info = _info;
text.text = _info.Name;
}
public void OnClick()
{
Launcher.Instance.JoinnRoom(info);
}
}
Got told to post it here
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Can anyone help
Do you have a Launcher in the Scene?
Is the singleton working correctly?
Did you misspell Joinn on purpose?
Yes i did misspell Joinn on purpose and the launcher is in the Scene. What do u mean by singleton
Well you use the word Instance which is usually indicative of a Singleton Implementation
You'll need to show us the Launcher class
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Ok so you've tried to make a Singleton, but you forgot the most important part
You need to assign the static field to something
Usually in Awake, you'd run Instance = this; or something, people usually add checks here to ensure that they don't have two of the script in the Scene
Ok i have done that but now everytime i keep starting the game my prefab object in my Launcher inspector removes it self
Hi! i am using photon. Why these gameobjects move a little when player that created it leaves? CleanupCacheOnLeave is False. And it only occurs on NonMaster clients
I would check if something funny is sent through the transform sync
Can anyone plz give me network movement code because my $tupid script isnt working
i need help about photonengine
I have such a ball it moves perfectly when the game creator hits it ,but when the others hit it it lags and comes back slightly ahead of the place before hitting it
pls help
What's the value of your PhotonNetwork.SendRate? It should be set to something like 30 so it keeps up with movement
Are you talking about transform view?
im new on photon sorry
this ball components
this player s components
its a static variable
you do this in code, preferrably on an Awake() function of a GameObject that's active from the start
PhotonNetwork.sendRate = 30;
PhotonNetwork.sendRateOnSerialize = 30;
on ball?
actually
make a new gameobject in the scene
and make a new script
name it something like SetSendRate
attach the script to that gameobject
yeah
make a public field called sendRate and default it to 30
then make an Awake function with
PhotonNetwork.sendRate = 30;
PhotonNetwork.sendRateOnSerialize = 30;
i trying thx
@dusky leaf there is some improvement but not fixed ):
i think relevant lerp
transform view
do you mean the ball returns to default position when non creator hits it?
yeahh yeah yeah @cobalt python
Does anyone know how to use unet matchmaking in WebGL?
only creator can move his object. You should transfer object's ownership to other player that hits it
how can I do it
set owner field in PhotonView component of the ball to Takeover
and set in ball script:
void OnCollisionEnter(Collision contact)
{
if (!photonView.IsMine)
{
Transform collisionObjectRoot = contact.transform.root;
if (collisionObjectRoot.CompareTag("Player") || collisionObjectRoot.CompareTag("OtherPlayer"))
{
//Transfer PhotonView of Rigidbody to our local player
photonView.TransferOwnership(PhotonNetwork.LocalPlayer);
}
}
}
but modify Tags or delete it
thanks i will try it
make sure your ball script inherits MonoBehaviourPun
@cobalt python All characters connected to playerfab, for example, the tag of the 1st player. Player, how can I set the tag of the 2nd player?
you can do in your player script
if (photonView.IsMine)
{
gameObject.tag = "Player";
}
else
{
gameObject.tag = "OtherPlayer";
}
that is more true :D
you can delete
if (collisionObjectRoot.CompareTag("Player") || collisionObjectRoot.CompareTag("OtherPlayer"))
if you dont need it
does you script has Using Photon.Pun on the top and inherits MonoBehaviourPun?
no i dont have
using Photon.Pun;
public class playerClass : MonoBehaviourPun
try in Unity edit, preferences, external tools, regenerate project files
thats strange, try to reimport pun
@cobalt python in here?
window PackageManager
ha okey
sorry i understand
@cobalt python
i mport this
they working but
i taking errors so much
importing again this
all working
okey
only this not working
@cobalt python
is it localplayer?
so much errrooooooor
i taking photonrealtime errors
Why does this script not work
But this does
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.UI;
using TMPro;
namespace Com.OcerGames.AirPVP
{
public class Launcher : MonoBehaviourPunCallbacks
{
public Color loading;
public Color connected;
public TextMeshProUGUI connectionState;
public void Awake()
{
PhotonNetwork.AutomaticallySyncScene = true;
connectionState.color = loading;
connectionState.text = "Loading...";
Connect();
}
public override void OnConnectedToMaster()
{
//Join();
connectionState.color = connected;
connectionState.text = "Connected";
base.OnConnectedToMaster();
}
public override void OnJoinedRoom()
{
StartGame();
base.OnJoinedRoom();
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
//Create();
connectionState.color = loading;
connectionState.text = "<b>ERROR:</b> Couldn't find populated room, try creating one yourself";
base.OnJoinRandomFailed(returnCode, message);
}
public void 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);
}
}
}
}
In the first script, when trying to join a room created by someone else you instead join an empty room
i need go i will try thank you so much for everything
Im having a problem with this script
If i create a room in the Unity Editor and then try to join it throught he built version, i dont see the other player even appear in the editor but they joined their own room
Ive tried debugging and when trying to join a room the script doesnt even get to OnJoinedRoom
Everything broke when i tried to follow this video tutorial series https://youtu.be/VHdLauXAYZw?list=PL6PsTmPNvw0eZirNDjO8dL0Y6X0ZFGaMt
We learn how to set up our players' profiles in this one broh...
Follow Welton on Instagram: @welton.king.v
Join our Discord: https://discord.gg/vrErfxa
Catch up on Github: https://github.com/Kawaiisun/SimpleHostile
BFXR: https://www.bfxr.net/
Piskel App: https://www.piskelapp.com/
Audacity: https://www.audacityteam.org/
...
It worked before and i didnt test it inbetween
Only before and after
Please @ me if anyone can help so i see any responses
Make sure to check you are on the same region
hello; I try to learn how create a launcher for log in my game but I have a problem: my first scene is the login panel + character selection. I have a login script (when I enter the correct informations, I can select a character) and a NetworkManager script for Connect my player to PUN server. Then with OnJoinedRoom I load My gameScene with GameManager script.
my first player can load the scene well with good information; my second client when I login is just a clone of the first, even if In the login scene, I have the second user informations
How are you storing the info? I assume all players share their info with everyone else in the room
I have Sql DB, I have a script with Json for translate from PHP to C#
this part of the job is ok
Scene1 Login Window
Scene 1 character selection
And when I click enter game ( connect PUN with character information name + ID)
Don't understand how collect information to Scene 1 to Scene 2
ive region locked it through photon
but that doesnt really matter since the person joining doesnt even get to the " OnJoinedRoom "
function
@limber holly So is the server returning wrong info or are you somehow overriding stuff through PUN?
If anyone can help me, plz DM, Im having a connection issue
@mint sundial you forgot bracket
really wqdkşjwqfjwq
hey guys, I'm trying to make an HTTP request from Unity. My code compiles but does nothing. The same request as a curl does what I want it to in Postman. Can someone please help me figure out what the problem is?
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Data;
using System.Deployment;
using System.Drawing;
using System.Management;
using UnityEngine.Networking;
using System.Web;
using System.Net;
using System.IO;
public class JogAxesPostRequest : MonoBehaviour
{
public void ExecutePOSTJogging()
{
var url = "http://localhost/rw/motionsystem?action=jog";
var httpRequest = (HttpWebRequest)WebRequest.Create(url);
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.Headers["Authorization"] = "Digest RGVmYXVsdCBVc2VyOnJvYm90aWNz";
httpRequest.Headers["Accept"] = "application/json";
httpRequest.Headers["Content-Type"] = "application/x-www-form-urlencoded;v=2.0";
var data = "axis1=9000&axis2=9000&axis3=9000&axis4=9000&axis5=9000&axis6=0&ccount=0&inc-mode=Large";
using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
{
streamWriter.Write(data);
}
var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
Console.WriteLine(httpResponse.StatusCode);
}
}
Here's how the working request looks like in Postman
hello there everyone
i hope everyone is doing great
so basically i ran into 2 issues
this one
and this one
could anyone please help me right now i am in desperate healp
thanks
wait i fixed it thanks to anyone who wanted to help
i still ran into an issue
the part of script that is getting the error
the error im getting
so i fixed it
but it doesnt teleport me to the next scene
it stays on connecting
so this is the script please send me a dm on what i got wrong because ill need to sleep rn
ha anyone used Photon Bolt?
The damn wizard pops up all the time whenever scripts recompile and always gives an annoying "Are you sure you want to close the wizard" prompt every time I close it. Is there a way to stop it from doing this without digging around in their code?
I think you can get more specialized help in the "Photon Bolt" Discord
hi, anyone here use Mirror before?
Does anyone know why my phonton create and join room isn't working?
here is the code
```public InputField createInput;
public InputField joinInput;
public void CreateRoom()
{
PhotonNetwork.CreateRoom(createInput.text);
}
public void JoinRoom()
{
PhotonNetwork.JoinRoom(joinInput.text);
}
public override void OnJoinedRoom()
{
PhotonNetwork.LoadLevel("RandomFallingObjects");```
}
I get this error
CreateRoom failed. Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
You first of all must connect to master servers, is it your whole code for connecting?
Hello guys, I am implementing an online multiplayer Board game with Unity and Photon. I am still hesitating about using either the MVC architecture or the EC architecture. What do you think is the best architecture pattern for these types of games in Unity and Photon ? Should I separate the Visual from the logic ?
If you don't really foresee a reason for separating logic from the visuals, I would just stick to the Unity way until you have practical reasons to switch.
I am particularly a fan of decoupling gameplay and view
Although PUN/PUN2 were designed around the unity standard coupled/mixed way...
But Photon Quantum, for example, enforces a clear separation... And in Fusion we both "encourage" it (with visuals normally being only interpolation targets), and "enforce" it with the special FixedUpdateNetwork method for tick-simulation, etc.
So, it's not a wrong decision to try to decouple IMHO. It generally pays off in the long term.
(copypasted from #💻┃code-beginner )
So... never worked with networking before, and my Unity knowledge is pretty basic so far, although I can manage C#.
Is there any tutorial for multiplayer over network? What I found so far doesn't suit my needs; I need my players to have a 'cursor' (an object used to navigate a menu) and a menu, but everyone should see their own personal menu, something like an async RPG, that when all the players made their actions/choices, the server would advance the AI.
The point is, I need to show every player a different menu+cursor, they want to navigate their own thing and the send what they want to do, and wait for other players.
Should I go for MLAPI? Mirror? Other? ...
mlapi imo
Are there any tutorials/how-to's? Couldn't find much by googling around
Is anyone using Pun2 Currently? They made an update a couple days ago that removed the place for Voice ID and I can't find anything on the internet about it
Normally it would be under App id Chat
Hi I`m making a multiplayer car game using Mirror. Every Time Player one chooses his character everything works fine. When Player two chooses his character he gets only the same character like the first player. Any Ideas?
Here is my code (The set Active lines are for gui):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using TMPro;
public class CharacterSelecter : MonoBehaviour
{
public NetworkManager manager;
public GameObject Player;
public string Name;
public TextMeshProUGUI Name_Textbox;
public GameObject Foxy;
public GameObject Kaktus;
public GameObject Otter;
public GameObject Pinguin;
public GameObject setActive;
void Awake()
{
Foxy.SetActive(false);
Kaktus.SetActive(false);
Otter.SetActive(false);
Pinguin.SetActive(false);
}
public void ChangeCharacter()
{
Foxy.SetActive(false);
Kaktus.SetActive(false);
Otter.SetActive(false);
Pinguin.SetActive(false);
setActive.SetActive(true);
manager.playerPrefab = Player;
Name_Textbox.text = Name;
}
}
How would I go about declaring a global variable in a jslib file? I tried
mergeInto(LibraryManager.library,
{
var test = new WebSocket("some url here");
});```
but then the webgl build kept failing and I can't find any info on this besides one link
I want to store a global websocket for the webgl application, but I'm not sure how to go about implementing it
The way you declare a global variable in a jslib file is by using this library from this repository and forgetting about all of that JS baloney 😉
https://github.com/endel/NativeWebSocket
That naming "NativeWebSocket" is confusing. It's not native (as in C/C++) but managed (as in using .Net ClientWebSocket) for standalone builds.
I am using Firebase in my unity app, but the app crashes on android when moving from Authentication scene to Main page scene, I installed Firebase Crashlytics, and the error says java.lang.error, what does that mean?
hi, is anyone familiar with the new mlapi ? i need some help understanding where my problem comes from
What's your problem?
fixed it don't worry
@brisk briar have you checked that your firewall isn't blocking?
It appears to be a version mismatch between the ENet versions you are running for server and client.
That link suggests building them yourself.
Simplest suggestion is to just write both client and server using ENet-csharp
I guess native as in native to JS in a browser, after all, there is literally no other way to do it
as someone who failed at unity game netcode for logner than i want to admit, and trying lots of solutions, i would suggest this to anyone starting out, (its pun 2, but it gets you up and running and is actually good code, dont watch the youtubes) https://github.com/wafflehammer/FPS-Game-Tutorial
with a lil tweaking, you could even chop it down to just realtime which is what the latest unity mhalpi used as transport
just before you raise concerns such as, 'photon isn't server authoratative' first of all that's not really even the right accusation in the first place, as it default has a relay (server-ish) yoou can extend, and most importantly, if you are at this juncture, i think the bigger issue with not having this magical server side authoratative code you dream of is that you don't have a working networked game to be hacked yet lol, and unles your steve wozniak you can't stop it from happening, just mitigate things that are not ESP/passive, but all that is netcode solution agnostic
With PUN2 when I throw an object, it'll look fine locally when it hits a surface, but on other players clients it like slides slightly and then does the physics.
Anyone know a fix for it?
Yo, is anyone here experienced with photon framework?
How to run 2 games at once in editor?
You can't. You need to make a build, run that and run the editor.
Depends on which network tool you are using
Both fusion and quantum support running multiple clients (and server in case of fusion) from the same editor
And a workaround for frameworks that don't support that: https://github.com/VeriorPies/ParrelSync
Which can also be achieved@with a simple symlink pointing to the project asset folder (from@another location)
Then you can open two editors
what network tool will be best? I don't want to just assign elements/variables to be synced, I just want to send Messages, I will do the rest with the scripts
and will be great to have external server
Well, if you just want to send messages you are saying you can do better than the tools that do a lot of features for you
I didn't said that, I just want messages
But in that case anyway, you are looking for a basic transport layer only
yeah
Steam networking, photon realtime, epic game services, etc
I mean, there is a ton more to game networking than that
but for steam networking I need to buy token for $100 if I'm not wrong
So unless@you have a very very simple game in mind, you may want more
For networking you will always have some service involved, unless you are talking about LAN only
https://github.com/Facepunch/Facepunch.Steamworks I will try this I think
Great
i almost responded lol, but nah, listen to this guy, hes kinda a big deal in photon related things
What guy
the erick guy
its like zuckerburg personally adjusting your privacy settings for you i'd listen to him
hi, i'm using the new unity mlapi and i have an issue, when i try Hosting a game the host player gets assigned as Host and then as Client to that host as well, now the problem is : when the Host player stops hosting, he gets removed as Host but is still in the connected Player list. I've found someone that had exactly the same problem then me on github but the only answer is that it is a bug and it should be fixed soon, but this was posted nearly 2 years ago! Does anyone knows how i can disconnect the Client side of the host aswell?
Like on the same frame or does the host stay on the list forever?
well in debugging the connected client list count in update and its always 1 after the host started once
forever
Hi, having trouble finding out the best way to do this: Player spawning and respawning. Respawning is easy enough (I think) but I'm having trouble with when the player object gets spawned when they join the server. I can use the OnConnectionApproval delegate, but that only works on clients, not clients AND the server host client player object.
Should I handle spawning manually with a script instead of using MLAPI default player object? or is there something else I can override because right now the server host client player object just spawns at 0,0,0
I figured out that NetworkManager.Singleton.StartHost() takes in the same parameters as the connection approval delegate like position and rotation, but still wondering if someone has insight into this and if there is a better way :)
what is a good method of sending the active keys being pressed to the server?
char
a bitmask
find where windows handles the heypresses and hook that so you can get value as its loaded into a register (may not be compatible with windows defender)
I prefer treating the player object nothing more than a connection interface for clients
When a player joins, it gets spawned automatically. It only gets destroyed when the player leaves.
And the actual character is a different object you may spawn and destroy when needed.
@valid totem Probably just send a message to the server that I would like to spawn now and the server responds by adding the player or by some other message.
that seems like a much better idea. Right now I'm just deleting the player object and respawning it when they respawn but I see how this could cause catastrophic errors and issues in the future when the codebase gets a lot more complicated
thank you all
<3
Every player in my game has a public int deaths and theres a manager in the scene that im wondering how i would sort every player by deaths and get the player with the least deaths
using ExitGames.Client.Photon.StructWrapping;
using Photon.Pun;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class Manager : MonoBehaviourPunCallbacks
{
public string player_prefab;
public Transform spawnPoint;
public static int deaths = 0;
private bool hasSpawned = false;
public float time;
bool hasDetermined = false;
List<int> l_deaths = new List<int>();
List<Transform> l_players = new List<Transform>();
public void Spawn()
{
PhotonNetwork.Instantiate(player_prefab, spawnPoint.position, spawnPoint.rotation);
hasSpawned = true;
}
public void Update()
{
if(hasSpawned)
{
time += Time.deltaTime;
if (time >= 10) //just for testing purposes
{
DetermineWinner();
}
}
}
void DetermineWinner()
{
if (hasDetermined == false)
{
GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject go in players)
{
if (!l_players.Contains(go.transform))
l_players.Add(go.transform);
}
foreach (Transform t in l_players)
{
if (!l_deaths.Contains(t.GetComponent<PlayerMovement>().deaths))
l_deaths.Add(t.GetComponent<PlayerMovement>().deaths);
}
l_deaths.Sort();
int winner = l_deaths[0];
foreach (int i in l_deaths)
Debug.Log(i.ToString());
foreach (Transform t in l_players)
{
if (t.GetComponent<PlayerMovement>().deaths == winner)
{
t.GetComponent<PlayerMovement>().DisplayWin();
}
}
hasDetermined = true;
}
}
}
[PunRPC]
public void DisplayWin()
{
Text winnerText;
winnerText = GameObject.Find("Canvas/WinnerText").GetComponent<Text>();
if (photonView.IsMine)
{
winnerText.text = "WINNER";
Launcher.myProfile.xp += 20;
DataLoader.SaveProfile(Launcher.myProfile);
}
else
{
winnerText.text = "LOSER";
Launcher.myProfile.xp += 10;
DataLoader.SaveProfile(Launcher.myProfile);
}
StartCoroutine(DisconnectUponWin());
}
please @me with any responses / help :D
Can someone explain why I am getting this error when using NetworkServer.addplayerforconnection?
Exception in MessageHandler: InvalidCastException Specified cast is not valid. at Mirror.NetworkIdentity.SetClientOwner (Mirror.NetworkConnection conn)
What's the difference?
If you click on them they have it described
But mostly on Unity PUN (Photon Unity Network) is used
Can I use pun for fps games?
Tho it states that bolt is perfect for fps/tps and battle royale games
I've use photon on a normal platformer game before
It was laggy because I used transform viee instead of rigidbody view
Yeah Bolt is better for FPS, PUN is for casual multiplayer
after doing some research, I am confused.
Should I use mirror or photon?
I want my game to have different rooms and more that 20players in a server. Photon only allows to 20 CCU per server, so should I create a new server? or use mirror?
mirror doesn't have any CCU limit but I'm worried if would be realtime or not
I want the server to be created at host's pc so that I don't have to worry about the server and ccu limit
Also, what networking solutions do big games like valorant, csgo, pubg, amogus use?
I asked this question about 4 times and no answer to this day, but in 2021, as a beginner, where should I start for networking?
Photon pun
PUN allows 20 CCU in total for a product free, but Mirror requires self hosting or peer to peer
could you please explain me what's self hosting and peer to peer? Also, would the lag be same if using self hosting or pun?
Self hosting is what it is, you host dedicated servers or you let players host dedicated servers
Peer to peer is to allow players client's to host a game that people can join, the host player would have to port forward or you'd have to implement some form of relay service
Among us use peer to peer?
Not sure, never decompiled their source code
Phasmophobia uses Photon PUN I believe
so, I should use mirror instead of pun?
That decision is entirely yours
Photon also has a service called photon bolt which is made for fps and battle royale games, so I was wondering, would the game be realtime with a little lag in mirror too?
Or is mirror just made for classic games?
Lag is a result of many factors
what about server side lag? Like how much time it takes for the server to calculate the position of a player and send it to other
Again, if I run a server on a Pentium and dial-up internet, it'll lag more than a Xeon with fibre internet, I don't know Photon's specifications
It would be best for you to go and look into using both of these solutions, watch some videos and see which is right for you
Alright thanks, ig I'll be using photon pun or bolt for some time and then research about other networking solutions
Every player in my game has a 'public int deaths' on them and theres a manager in the scene that im trying to sort every player by how many deaths they have and get the player with the least amount of deaths
using ExitGames.Client.Photon.StructWrapping;
using Photon.Pun;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class Manager : MonoBehaviourPunCallbacks
{
public string player_prefab;
public Transform spawnPoint;
public static int deaths = 0;
private bool hasSpawned = false;
public float time;
bool hasDetermined = false;
List<int> l_deaths = new List<int>();
List<Transform> l_players = new List<Transform>();
public void Spawn()
{
PhotonNetwork.Instantiate(player_prefab, spawnPoint.position, spawnPoint.rotation);
hasSpawned = true;
}
public void Update()
{
if(hasSpawned)
{
time += Time.deltaTime;
if (time >= 10) //just for testing purposes
{
DetermineWinner();
}
}
}
void DetermineWinner()
{
if (hasDetermined == false)
{
GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject go in players)
{
if (!l_players.Contains(go.transform))
l_players.Add(go.transform);
}
foreach (Transform t in l_players)
{
if (!l_deaths.Contains(t.GetComponent<PlayerMovement>().deaths))
l_deaths.Add(t.GetComponent<PlayerMovement>().deaths);
}
l_deaths.Sort();
int winner = l_deaths[0];
foreach (int i in l_deaths)
Debug.Log(i.ToString());
foreach (Transform t in l_players)
{
if (t.GetComponent<PlayerMovement>().deaths == winner)
{
t.GetComponent<PlayerMovement>().DisplayWin();
}
}
hasDetermined = true;
}
}
}
And here is the function of making the player win
[PunRPC]
public void DisplayWin()
{
Text winnerText;
winnerText = GameObject.Find("Canvas/WinnerText").GetComponent<Text>();
if (photonView.IsMine)
{
winnerText.text = "WINNER";
Launcher.myProfile.xp += 20;
DataLoader.SaveProfile(Launcher.myProfile);
}
else
{
winnerText.text = "LOSER";
Launcher.myProfile.xp += 10;
DataLoader.SaveProfile(Launcher.myProfile);
}
StartCoroutine(DisconnectUponWin());
}
Please @me with any responses so i see them :)
Nevermind i got it working haha, the DisplayWin function just got called for everyone but i fixed it :)
Uhm, so I have aproblem. Yesterday I had an error in the console that I read I can fix by updating photon. So I did update photon and the error dissapeared. The only problem now is that my in game chat suddenly stopped working. I've entered the correct appid and etc. any ideas?
Problem solved, I had to make a new appid for the chat
Hey guys, just a quick question, how hard is it to get into multiplayer? I just think I might not be ready for it yet... Are there any key concepts that you'd need to know before jumpin in? Thanks
Go for it, learn by doing, just if you already have a project you want to try to make multiplayer know you're most likely going to break it and its a lot more difficult to make multiplayer afterwards instead of going for it from the start
Yes, I'm a bit experience with Unity, I've been using it since 2019 or so, but I'm unsure what Multiplayer library to use.. PlayFab, Photon, there were some other that got outdated. What do you recommend I start with?
I have a maybe silly question, but when using MLAPI, is there some reason to not call a serverRpc on the server itself?
Does this cause it to send another network request?
Specifically, in the golden path example, in the move function, it seperates out the server check for setting position and transform from the in the hello world player, but removing that and only calling the serverrpc instead seems to function correctly.
I can't seem to get the network profiler working for it either, so it's hard to tell if any packets are being sent.
The following table details the execution of ServerRpc and ClientRpc functions:
@olive vessel Perfect, thanks so much.
I hope that helps, it says it queues them so I can only assume it does not go out to come back in
Yeah, it's not 100% clear on that, but I'm assuming it's an issue with some memory allocation since it looks like the framework injected code would cause it to be sent on the loopback, which makes sense, but also means I do need to keep them seperate I think.
I mean, it functions as expected, but yeah, it's gonna queue and be slightly slower as well as spinning up the network writer so, I'll just handle the diff manually. It'd be kinda nice if it just detected that, but I also understand lol.
In a general multiplayer game scenario where the game contains a library of many RPG items (scriptableobjects), how can I create a runtime database of these items for network references via unique ID?
Say I send an RPC to communicate that a player has picked up X item.
I am tempted to use resources folders to automate the database generation but it seems to be discouraged
@versed socket If your item SOs are going to always be in memory anyway, it probably doesn't matter, especially if you then don't reference the prefab directly, but by AssetReference or something equivalent.
It's pretty trivial to connect and send packets around using a transport, but the architecture on top of that can be quite time consuming. For high quality networking it's likely not enough to just send state and be done with it.
I'm making active 2d ragdolls but when I connect to a server (with photon) the ragdoll just breaks and flies off
anyone know whats going on?
Do I need a certain component on each ragdoll piece? for photon maybe like the photon transform view classic?
you have a nested hierarchy of rigs on the active ragdoll?
i leveraged photon for my 3d active ragdoll game, and my netcode is fantastic now, after spending a long time on it to the point i lost sight of my games purpose lol
If I have a server scene, and a client scene in my unity project, using Mirror, how do I call a function from the server scene if the client has no visibility of it?
you talkin bout the concept of a remote procedure call?
Basically, yes... but all examples of this I've seen it say [Command] <some function> and then the actual code to execute is contained within that method/function on the Client... I do not want that visible to the client.
What I want it to be like is;
[Command] CmdDoStuff() {
HeresAnotherFunctionorMethod(stuff to send)
}
and then in the server files, that 'HeresAnotherFunctionorMethod' has its own code chunk that's private to the server
but how you gonna run code if you dont have code to be run
its not magic, its netcode (smoke and mirrors)
lol, that's exactly my point. I want the server to understand what that function/method is, and call it, when its told to call it
the client doesn't need to know what the code is
if you say server autoratative determinalistic loud enough over here, nobody can tell that everything works more or less the same lag comp is stupid if you raycast cause it solves itself and rollback is 100% retarded and absolutely a terrible idea except for nickeloadean based fighting games (ok fighting games, but you have to live with the consequences)
additionally, no matter how many buzzwords your 'server' has, can't stop esp autoaim or you know, all the popular, passive cheats
you can add a bunch of latency tho, so thats pretty dope
I need to contain a password for a mysql account that's reading a local configuration file with the password being encrypted... the encryption needs to be done on the server only.
uhm, you need ssl and possibly leverage some windows api stuff if you REALLY cant have user type it in themselves
users won't know what the password is
so you have a master password, for all the things, and you need your clients to login with privledges to this and i'm curious what you think the outcome will be
alas, that side isn't the problem... it is literally just the concept of how do I tell the server, from a client, to run a method that the server knows exists, that the client doesn't know exists
sql injection?
have you ever played Arma3?
ok, there are various mods on arma 3 that allow for mysql data capture, to "save" player progress
why does that have to be a master account for everyone, i'm certain it uses individual users account
on the server, there is a configuration file, it reads and writes the mysql data
it has a single account
and it probably piggybacks off a third party auth
for everyone, in the world, with full read write
the clients, people playing arma3, connect to a server, and they literally just send a single function to the server, and say "run this function"... which is the mysql function... the data is stored
that's all I'm trying to emulate
server is the only machine that should have access to its own local mysql database
like, a post request?
it reads, it writes, it just relays the information
yeah, sure... but how do I get the client, to tell the server, to run a c# method?
why would the game file be hosting a www instance?
and how would mirror interact with that?
i thought it was an sql server you wanted to talk to directly
as you just stated
not a c sharp method
no, its the game server, which has its mysql instance running on it... I want ONLY the game server to read/write it, on request by the clients
so how do I tell the server, to run a method that only it knows, when that code has to be on the client?
so tell the server to run a method that then runs the sql query?
like the reason I originally left out the mysql stuff is because you've zoned in on that being the solution, it isn't lol...
I need to know how to run a method from the server, when the client makes that initial call
like client clicks Save > Save is passed to server > Server runs the save function > Data is saved in mysql > response is returned that data is saved > Save state is passed back to client > client is happy
why not player prefs
huh?
just store it locally in player prefs
I can't store it locally... if the game has ultimately enough funding, it's intended to be hosted on a cloud platform without local data
ahah, and here is the most important question in netcode
before you try to solve your hacking/scaling problem, your number one priority should be to get the worse possible hacking/scaling problem possible
which as it stands, is not being able to send a command over the network manager to call a function that the client can't see
without that possibility, I can't build the rest of the game
so right back to the beginning of my question....
How do I do that? All examples online simply show clientRPC and Command etc with all of the code clearly visible in the same files...
Yet everyone recommends splitting server and client into two separate builds so that you can't see the contents of the server code
and thus, my issue
how do you have any working netcode if you cant call methods on other clients/server (no difference really in the means in which you do so right)
i mean, do you want to call a method on the server, that doesn't exist on the client? no problem there right?
yhou can build a separate server build
ask for method by name
Yeah, I want to do that exactly, but there's absolutely no examples of htat
how do you normally call methods on other computers
I don't know... I'm learning, hence the blue name
oh i ddin't know they did the racism name struff why am i green, isn't that more less experience than blue lol
oh i picked this
Yeah, I'm just student, because I'm learning
yea i'm not a game dev, its accurate, unity makes me feel like i need a shower
i can code tho pretty aite
I can code normal applications, but I don't write applications that network multiple machines together to constantly exchange data
I also have no experience in web dev either
same here, game netcode is very strange, if it makes sense, your probably going down the wrong path
i use photon personally, after going through mirror as well as unity mhalapi
but alas, that's diverging off topic...
When I write a function on my client operations script file, and tell it its a command to be ran on the server, and then reference the function by name, it just gives me a syntax problem saying it doesn't know what that function is
i tried it, ditched it, tried everythign else, ended up back on oit
but I expect that, the client isn't supposed to know what it is
but I can't run it, because it doesn't know what it is, and that's my problem
you should be sending a string and using reflection if i'm not mistaken
or like
invoke("methodname")
ah ok, what's reflection?
reflection is like yo u know that variable thats like private? i don't care
ah ok
now
the thing about sending invoke("methodname")
across the internet
is i really want to play your game
for science
when it comes out
tbh, from what I recall actually... "BIS_fnc_MP" that was a method that basically was used to call other methods
so it'll be the invoke I need
champion... thank you 🙂
sure, give me 5 years hahaha
i spent way too long on netcode, now not to brag here, but my netcode is dope af now, its just like, i completely lost sight of my game and any purpose or direction it had
well mine will be utterly terrible to begin with, but hopefully it could be optimised later on down the line
lol I don't know whether to be impressed or disgusted
typically people say things like wat is this insane fever dream, i'd go with taht
MIRROR 44.0.2 IS LIVE ON THE ASSET STORE
Download: https://assetstore.unity.com/packages/tools/network/mirror-129321
ChangeLog: https://mirror-networking.gitbook.io/docs/general/changelog
Nice!
Wdym?
my game being active ragdoll didn't like, fall into any tutorials or assets or prefabs or existing stuff out there and i had to do it custom. i learned a lot, my netcode is really really good (33 bytes and a bool to sync 15 rigs) but like, i lost sight of my game and its purpose entirely
Wait you said you used photon?
yaa
one nice thing with photon is you can use it at a low level if desired, and at that point its as efficient as you are you know
like, the unity mhalpi thing they put out most recently used photon for transport
quick question tho
how did you make your ragdolls not fall apart
in multiplayer?
configurable joints
and also custom drag/angular drag handlers along with inertial tensor jobbers
@gentle mirage Invoke doesn't seem to be acknowledged as anything I can call under either monobehaviour or networkbehaviour 🤔
u gotta use an alley ooper method the sme way your currently doing netcode stuffs but have it invoke thje argument
my ragdolls work
but when they connect in a server
they like break and fall apart
like they work normally
ur usin photon pun 2?
I'm using a NetworkAnimator component (Mirror). At the start of my game it throws this error:
Animator is not playing an AnimatorController
UnityEngine.Animator:get_layerCount()
The related game object is deactivated at the start of my game. Will this cause the issue?
I'm asking this again cuz I'm dumb, I want the server to be created on host pc and no CCU limit, how can I do that?
I used photon pun but it has CCU limit of 20 and works as dedicated server
But I want my server to be instantiated wehn the host creates room
That's called (player hosting/ listen server) you'd want to use Mirror or MLAPI for that
Ight, thanks
or photon fusion
Question about networking: I need to develop a simple Rock Paper Scissors game where 2 people in que gets paired and play a game, can I do this with p2p?
Peer to peer is just a way of connecting people, so yes
Im not an expert on networking, I basically dont want to rent a server since I guess that is not needed for a game that simple, am I right?
@cedar cloak @inland sand Just note the details when it comes to hosting a server behind a network firewall. Average player will have a hard time with port forwarding.
Photon PUN is probably not a bad choice for your Rock Paper Scissors game
20 free CCU
Rooms etc
I already used him in previous projects and 20 CCU is too few
Yup
20 CCU is too little? You must be having some good success then
Someone once did a breakdown, of how CCU translates to MAU, and you need thousands of MAU before you start hitting even 1k CCU
Hi guys, I am using pun! Someone said that using rpc buffered is a very bad idea, is it?
Hey all I have been looking around at various networking solutions. As far as multiplayer games go Unity has had the general reputation of not being so good in that regard. Realistically how hard is it to get networking right in Unity vs unreal? I know Rust and Escape from tarkov are multiplayer unity games but each of those has had issues and I believe tarkov atleast made its own custom networking.
it depends what you gonna do. Buffered RPC sends all past messages whenever player was not in the game
Would I need a certain component on every gameobject in the ragdoll?
Unity's own networking is pretty bad right now. 3rd party solutions are better, such as Photon or Mirror, depending on your needs, what type of game it is, CCU expectations, etc.
When i use photon pun my active ragdolls break like this anyone know why?
do I need a certain photon component on the gameobjects of the ragdoll?
Photo network.instantiate
I knew that
Does photon have dedicated servers? If the master leaves a room, does the master pass to the other player?
how would one go about networking charcontroller height?
Hello, I working on 2D mmo, I wondering about the most efficient way to build the character or enemies ?
Currently, I instantiate Player prefab with:
- main script, controller script, scriptdata for DB character informations)
- The UI ( statut windows, skills, maps etc)
Now I scripting the combat system, then I want to create another GameObject Child of PlayerPrefab with the character skills ( graphic effect, templates etc). I wonder if this way, my player is not to eavy for the server ? Is it better to Instantiate each time the spell from the game folder ?
Why are there very little tutorial on making fps with unity?
Please suggest some good tutorial/playlist on how to make one with mirror (I've some experience with photon)
Even Brackeys has a multiplayer FPS tutorial, granted for UNet but still, demonstrates a lack of research if you believe there are "very little"
But it's so old
Doesn't mean no skills are transferable. I bet there are a tonne of tutorials for FPS games, and a tonne for Mirror, so then it's a matter of understanding the content and applying it.
Ofc UNet is gone, but you can see how the processes worked with UNet and try and bring that forwards to Mirror
Ight thanks
VERY IMPORTANT QUESTION, in photon unity networking (PUN)
if I make a photonview with a transferable ownership.. would photonview.ismine refer to the new owner????
thank you in advance
you're welcome in advance
Hey everyone. Can someone help me out with a weird issue in UnityWebRequest, the downloadprogress keeps returning -1, not finding any doc about this behaviour
Nvm, it held the webrequest and did not start it before hand...
Hello, Moving this here as general code might be the wrong spot.
I am curious if anyone has used MLAPI with Steamworks.facepunch and would recommend using the SteamP2P transport or just using the Unet transport?
Yes, the new owner would get a true for ismine.
I see a lot of videos and people talking about mlapi , is it better than photon ? and thank you
I moved to MLAPI since it does not require a server for players to connect to. (I cant afford that)
I want my players to host the game and others connect to them.
This works fine for smaller games or games that are ok with one person having a lot better ping than the rest.
Pun may be able to work P2P but I did not see an option for it.
I thought pun provided free servers for games with a limited amount of players
They do. but that only helps for up to 20 players I think.
I want to end up putting my game on steam and the hope is more than 20 people would play. 🙂
oh... they mean 20 player for the whole game. ... not per match 💀
This is what I got out of reading it. Not 20 per server/game, 20 total
I could be wrong but thats the reason I went to MLAPI.
I used PUN as well for a while and had to restart after reading into it
do you have a resource for mlapi? like videos and such
if you dont mind sharing of course
Just youtube and personal trial and error
This site provides Unity Multiplayer documentation, references, and sample code tutorials.
They have a trial game you can download in Unity and read over there code
thank you
what does that mean
Okay, so I did read it right
Because not every player, will play at the same time
oh I am reading it now
💀
@remote rock one last question if you dont mind, since you already have started with mlapi , is it majorly built on events?
How to bypass CORS for unity webgl builds?
We are only getting 2 out of 9 response headers in unity webGL build but all 9 appear in Unity-Editor.
the prize of having photon is not a reason why you go out with empty hands... mlapi wasnt designed for rooms ( like 5v5 in league of legends thats what i mean with rooms) ... at its best its good for coop games or games wiith few scenes as the traffic scales exponential with scene management on
Its very similar to PUN with wording but the NetworkManager needs every networked object manually added to the list.
I would recommend watching a few videos on Starting up with MLAPI - https://www.youtube.com/watch?v=qJMXv5J4wf4
This is the first video in my new series on using MLAPI to make a simple multiplayer game in Unity3d.
Full Playlist here: https://www.youtube.com/playlist?list=PLbxeTux6kwSAseRmJeCyvkANHsI16PoM6
In this video we will setup MLAPI and a tool called UnityProjectCloner so we can more easily test as we develop without having to build the game every...
If you're not hosting servers, your players will need to port forward. Or you'll need a relay service or a punchthrough technique
My goal is to have 4 players playing in a single scene at any given point.
There is no other scene as the same scene will refresh in a sense.
do you have multiple groups of 4 players
Not in the same game no
more like 400DAU, 8000MAU
so you have at MAX 4 players AND all of them are on the same Scene
@placid oak @remote rock with mlapi can I make my own server and make the game run on it?
yes
Absolutely, just read the thing again online, incredible how it scales really
THEN go for mlapi definetly
to get 100 ccu, you need around 2000 dau, and 40k mau (50k + downloads)
And MLAPI for self host you still need a solution for punch (as port forwarding is only for nerds, really)
well damn I have the same thing.. only 4 players per scene... now this is scary.. i have to redo everything in mlapi
if you reach THAT point ... you dont have to worry anymore about the photon costs
Have you used Steamworks.facepunch with MLAPI before?
No, have not... It does work
If the game is Steam, sure... It works
If the game is steam only it is a valid option for p2p
if you have like league of legends :
per scene 10 players and multiple versions of them => you need photon
1 Scene with players on it AND all players are on it => MLAPI
Okay, this is what im currently doing but came here to ask if the SteamP2P transport is worth using or if I should stick with the Unet transport.
in the game.. I have 4 players, a unique prefab for each of them... and everything happens in 1 scene
Use SteamP2P if you want players to connect directly to a hosting client. Use UNet if you want your own servers.
is it possible to have 4 players play together
and then another 4 player groupe comes and they play also together
Okay, that makes sense. and I do.
I looked around and tried a list of things last night but could not find a way to get the steamuser info.
Have you used the facepunch before?
Its different from the normal facepunch functions as SteamClient.(anything here) does not yield the same results
from what I understand this would be fine for MLAPI. as long as they all play on the same scene
sorry i may have said it wrong i will rephrase what i said ... in my game.. each player uses his own PC... they connect to one room... in the room there are only 4 players playing, each of them controls a unique prefab
no in the room there are ONLY 4 PLAYERs
are multiple rooms possible where each of them "keeps" 4 players
if so then mlapi is a shot into your foot
you can make a giant work around with mlapi but it wasnt designed to have rooms which are independent to each other
So wait....
In my case there will be 4 players playing all on one scene. However, other people can play the same game but with there own group of 4. Completely independent from the other group of 4.
Would this be to much for mlapi
yes and mlapi sucks at doing that
Sh*t
Mirror can do that can't it?
NetworkRoomManager and NetworkRoomPlayer?
Ah, Network Match Checker
yes but why code it urself instead of using for example photon which patch the room management regurarly ... YES photon will cost you something at some point but you will have a higher cost buying someone who patches your room management
What would be the best option then for up to 4 players to connect to a single host. I am not able to pay for a server and my game would be fine with a player being the host.
The cost is tuppence
Then you need a relay service (Steam), punchthrough or just tell the players to port forward or host a community server
photon with ccu for 20 is free .... above they calculated that
I am sorry I dont get what you mean by rooms that are independent to each other
I really need a good Photon tutorial series actually...
ok lets say you have a scene with a temple in the middle and with 4 players on it trying to capture it
now 4 other players come and want to play also capture the temple ...
now the problem happens the first scene is ful so your server needs to create a new one where the other 4 players can play capture the temple
the first map and the second map now dont know anything from each other
And this would need PUN?
@placid oak no that is not possible , in the scene only 4 players are allowed NOTHING MORE there are no multiple maps or anything .... think about it as a cs-go match, there is only a specific number of players allowed... if others want to play the game, they have to create their own match
"the first map and the second map now dont know anything from each other" this is where mlapi fails as EVERY scene which is in the network is known by everyplayer
they have to create their own match <== this is your "room" or "the second map" in my example...
Damn I thought I new what I was doing.....
So MLAPI is unable to handle multiple rooms? Even if they are completely independent and running on user machines?
you can do it yourself with mirror or other network managers ... i use photon as they give me so much for a low prize...
if i would do the room management myself it would cost me mmuch more instead of just buying it from photon ... AND photon is free for 20 ccu
well no...
if your scene is in the registered scenes then EVERYONE will update it
if it isnt in the registered scene mlapi will ignore it but then only the local user can see it
wait .. if another room needs to be instantiated .. can't the other 4 players pick a "server" on the computer of one of them if we're using mlapi?
well damn
yes so a user starts an mlapi server on his pc but with any security this is a catastrophy
Question on Photon
how can I select a different map(scene) during the room creation?
so unless I want to make my own dedicated server .... pun is the choice
if I may ask you, is mlapi better than mirror?? IF WE'RE GOING TO USE OUR OWN DEDICATED SERVER
No
In Mirror, you can have lots of people in one scene, who can't even see each other
So one server can do many games
(i didnt make too much with mirror tbh)
as far as i know mirror is a low level api for networking => you can do ANYTHING yourself
mlapi is a midlevel api => work with what you got and you get alot but it has to fit
Okay, in my case the players go to a lobby and then they ready up and all move to the new scene. No older scenes are used.
Then if another 4 people what to play they connect to a new host/player and a new lobby is created just for the new players.
The first and second group have nothing to do with each other.
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!
that is what i wanted too for my game and thats it
that tutorial series
photon has pre implemented functions like "joinOrCreateRoom"
like you dont have to handle the rooms by youself
photon takes alot of work there
mlapi wasnt meant to do that
Hey, I have a problem with the Photon View and the Photon Rigidbody View, I am making a VR game and when I pick up an object, it does not sync to the other players?
photon has pre implemented functions like "joinOrCreateRoom" => here the user sends a request to the server that they need a new map and the server will create one for them
atleast you can implement it like that
@placid oak thank you a lot man this has been VERY HELPFUL
i deleted and rewrote it cause it wasn't a reply
that's what i am doing exactly but from what i got from @placid oak the new room would still be affected by the older one
even though it is a different match
yes as the scene management with the registered scenes must be available on each client
so in theory that IS possible
=> you create rooms
=> players dont see each other
but you are syncing ANY room ... and ANY scene even your match isnt there going on
that means your network traffic increases per user exponential
which is a catastrophy
hmmm, okay. So MLAPI is really only for a single game/room all together?
You are unable to have more than one group playing the game at one time??
as far as i got into it YES
and i got almost my game ready xD
dang... Is this a temporary thing for MLAPI or is this the goal?
you can read in many forums that mlapi isnt "the best option"
as far as i read and saw multiple times was that unity wanted to push the rework of mlapi as much as tehy could and now its more like a "secondary" problem
idk if thats true... but i only play games with rooms and matches so i dont want mlapi as the room management is like that
I restarted once because of PUN costs and now I need to go back 😦
How do indie games pay for servers like PUN? I imagine small games only stay alive for a short while and then die.
As someone said, 100CCU is a massive amount of MAU
Here
lets say yougot 1k players and 10 of them play a 10 euro bundle
you paid for the 100 ccu on photon ( 95 euros )
then you allready positive....
and above you can read i dont remeber the number like a few thousands of users can login per month
ye you need 1000 users where 10 pay but you can have 40k per month
=> photon prize is more than fair
Steam has over a billion accounts, but only around 120 million MAU in 2020
I am thinking the long term since its a monthly payment and I only plan to make my game a single cost.
There price is fine but im not looking to make bank with this game lol
$95 for 12 months
So if 100CCU is 50k downloads, 500CCU is a quarter million downloads
50k is fantastic really, 250k is incredible
Unless ofc, you make a game that becomes a fad, like Phasmophobia did
Yea I dont think that will happen. but fingers crossed right 🙂
I like that PUN has a breather so it will let people play even if its over 100 and you pay later
Have you used PUN with Steamworks.facepunch?
I've never really tried much with PUN, but I'd love to learn how to use it
Okay, Im sure there are videos or things out there.
Thank you for answering all my questions 🙂
Hey, I have a problem with the Photon View and the Photon Rigidbody View, I am making a VR game and when I pick up an object, it does not sync to the other players?
I had a similar issue a while ago and it ended up being a parenting issue. Not sure if thats it in your case
Ok, i'll try that.
seriously people i was terrified .. thank you for answering my questions
I can recommend you some play lists
Thank you, and sorry for pushing you in the wrong direction.
nothing to apologize for , you pushed me to what you think is the right option
It worked! Thanks.
Cool, glad that worked 🙂
Also, noted thing, no putting Photon View's on Objects with Renderers, because apparently that doesn't work.
How to get all response headers with UnityWebRequest.Post request for Unity WebGL?
@jovial pike your class should inherit from MonoBehaviourPunCallbacks, not MonoBehaviour if you want to override pun callbacks
thx 😄
i have another question
I changed my Unity Project Version and now this shows up
but it doesnt cause errors or so
Collaborate is technically a package I think, so see if you can update / remove (if you're not using it) it from the package manager
thx ❤️
parenting works perfectly when you parent it on other player scenes too
Hi, I have a 2D Game with 2 Players which i can controll with "w,a,s,d" and "i,j,k,l". is it possible to make a multiplayer with photon for this game?
In all tutorials are just one Player and the other is spawned automatically.
but my game is slightly different
can I let the host be the left Player and the joined Player is the right Player.
I dont understandy you
Im using Photon to make a multiplayer game
but idk how i can make that the joined player can controll the right character in the video
when the controller makes input he requests from the server to move that character
just
firstly you must have added Photon View for your player
then in Awake function getcomponent<photonview>(); to some object
and then where you have your code with getting input
check if(PV.IsMine)
{
// get my input
}
thx :D:D:D:D
i just have one
yeah but when you have two players on scene you have two cameras 😉
is there a possible way to make photon view + cinemachine cam?
ouh
I think it is possible but I didnt try it
mybe cine can register the view as cam to put the brain on it
this is the script for the right player
and he got his Photon View Component
both player have their own script
is that a problem?
you tested it?
the pv object is already set to pv component?
when the game is starting?
yes
so it should work
okey
is it ok if i dont have a lobby where i can create a room?
it connects directly to the game scene
from the loading scene
yeah for debugging purposes why not
what is not updating?
ahh because your players are rigidbodies
you also need add to them photon rigidbody view
ouhh
thx
photon view and the photon rigidbody 2d view?
or only the rigidbody one?
im trying both
it doesnt work 😦
do i have to check one of these?
i think all
i will try it
it strange that your positions are not synced
okey so you have only one camera per scene which players are not controlling
your players are PREFABS instantiated by PhotonNetwork.Instantiate, right?
nope
So there is your problem
that was my problem
thats a good idea
hey everyone! Curious about how difficult it is to create a multiplayer co-op game with cross-play between platforms. Let's say one player is on Windows/Steam and the other is on a Switch or ps5. Is it terribly difficult to allow those players to play together online? I've been doing some research and haven't come across a straight forward answer, so I'm not sure of the feasability or best practices on creating something like this
what is a good method of rotating a bone locally?
Anyone else had issues with mirror since the update?
The answer to that between WebGL/mobile/desktop is that it's pretty trivial, but can't say for sure when it comes to console details. Technically it shouldn't really be an issue.
You can introduce more variables if you rely on some sort of determinism, but I assume we are just talking about the networking part itself.
Thank you! I'm still a noob when it comes to networking but just glad to hear that it's possible and even better that it's pretty trivial. Really appreciate your input!
i think the Photon view Doesnt work as a prefab
You understand that you need a pro license to even build for consoles right?
other than that, I mean it really shouldn't be hard
Thank you! Financing the project won't be much of an issue for me, it's the knowledge that is the tough part
I mean yeah it really shouldn't be that hard at all
it's just sending/receiving data over the internet
which all of them can do
to actually get them to play together, is that just using a lobby code and then a friends list in the game? (for an example)
all libraries are different
so your networking library will need to support consoles
if they do, then yeah cross play won't be difficult
okay thanks, that gives me a very clear path of what to research next. I wasn't sure if Mirror would cut it or if I'd need Photon or something
Can that be my problem ?
Idk what to do
PhotonViews do work in prefabs assuming you use them after they have been instantiated
Make sure to use PhotonNetwork.Instantiate
Thx
So i just have to put „PhotonNetwork.Instantiate“ in my script
Do i have to say in which Player ?
thx
Sorry I went to sleep, just do PhotonNetwork.Instantiate in your network manager script
for ex OnJoinRoom callback
Is this how Photon PUN architecture works? Are masters also clients?
One of the clients indeed is the master(client), but all clients connect through a relay, not directly to each other.
Peer to peer over relay. Client <-> Relay <-> Client
and any peer can create an object and send data updates for it
so technically you can write a game putting some more logic on the "master", but it's not really designed for that
If you want a purist client-server netcode, with an accurate tick-logic, client side prediction, lag compensation, etc, go for photon fusion.
If I watch uNet tutorial then I won't be getting any problem using mirror right?
By now there should be Mirror specific content. The concepts will likely largely carry over, but Mirror has been in dev for a while since the UNet fork days.
PUN: Is there a way to reach the Player GameObject by using actor number or ID?
How do I store it? Can I use the Player var when OnPlayerEnter method occurs?
you can add "self" game object to a dictionary you store somewhere from a script Start
so every client knows which objects are spanwed by the others via their actor IDs
key is id, value is the object
anywhere you want
This is really about your own code, not something particular to pun, etc
I just need to assign the 2 player gameobjcets to the master and from them I can sync to the client I guess
I already store actor and ID of players
really strange I cant reach the Player go by using one of these two infos through photon
but yes, maybe I dont need that, I can compare just the IDs when calling an RPC
the point is this is not a 1-1 mapping (unless your own game treats it like that)
each player can spawn as many GOs as he wants, it's your code...
so it is not the role o pun to store that data
ok
So 'im having a little issue: The Player script is trying to call an RPC from the Master's Game manager script (its in the scene not on player), it has the [RPC] tag but I still get the error:
"PhotonView with ID 1001 has no (non-static) method "SubmitChoice" marked with the [PunRPC]"
public void SubmitChoice(string emitterId, Choice choice)
{
if(PhotonNetwork.IsMasterClient)
{
if (player1_id == emitterId)
{
player1_choice = choice;
player1_ready = true;
Debug.Log("Player 1 Submitted");
}
else if (player2_id == emitterId)
{
player2_choice = choice;
player2_ready = true;
Debug.Log("Player 2 Submitted");
}
else
{
Debug.Log("ERROR");
}
}
}```
this is the method
Mirror is a lot harder than photon :(
Join Our Community: https://student.dapperdino.co.uk/
https://assetstore.unity.com/packages/tools/network/mirror-129321
https://mirror-networking.com/docs/
-----------------------------------------------------------------------------------...