#archived-networking
1 messages · Page 115 of 1
pong
multiplayer and super simple dont fit together lol
Does anyone here understand how to script with pun 2?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OnClickFunction : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
PhotonNetwork.CreateRoom("SwordSlashersServer");
}
// Update is called once per frame
void Update()
{
}
public void Clicked()
{
print("Clicked");
}
}
How do I make a variable for photonNetwork?
@glass steeple I got help from the other server and set up some gui but I just want to make the server now. The issue is I have no idea how to access the variable PhotonNetwork. I just thought you might be of help cuz u seemed like somewhat of a pro xD
did you read some tutorial/doc/videos?
That's one of the first things they'll show you how to do...
Alr bet
Yeah I tried
But like none are specific to my stuff
Ima keep scanning docs
Yes because tutorials are made to be more generic, otherwise you'd need millions of varied tutorials
You should learn from a tutorial, and apply knowledge back to your own problem
Now that code there should error and tell you that you need a namespace, as long as your IDE is configured ofc
Yes
@olive vessel Assets\OnClickFunction.cs(10,9): error CS0103: The name 'PhotonNetwork' does not exist in the current context
So your configured IDE should give you a hint as to what you need to do
Or are we still at the point of Schrödinger's IDE with you? Where you say it's configured and it ain't?
It is
But like how do I get photon network
thats all im asking lol
@olive vessel
Sorry
I forgot its late at night i shouldnt bing u
what do you mean by it is?
how did you configure it?
which steps did you follow?
I downloaded it with unity
Like the ide
im using vs code
Dude I've shown 100 people at least screenshots of it erroring my code
And they all decided that you put too little effort to make it worth it to help you lol
@glass steeple
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
public class OnClickFunction : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
PhotonNetwork.CreateRoom("SwordSlashersServer");
}
// Update is called once per frame
void Update()
{
}
public void Clicked()
{
print("Clicked");
}
}
So now I have a error
In photon engine
And lapinozz no they were just making sure my lord
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.
UnityEngine.Debug:LogError (object)
Photon.Pun.PhotonNetwork:CreateRoom (string,Photon.Realtime.RoomOptions,Photon.Realtime.TypedLobby,string[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1782)
OnClickFunction:Start () (at Assets/OnClickFunction.cs:12)
wth does that even mean xD
Follow a tutorial
Ok I keep looking
You'll need more curiosity and hardwork to achieve a networked game. Getting stucked at "How do I make a variable for photonNetwork?" is a really bad omen. Don't want to be harsh 😉 just setting right expectations
I am using MLAPI - is it possible to send a reference to a scriptable object out of the box?
No there's no built in support for that.
How come this isn't possible in a steamlined way? Coming from Unreal, you are able to easily send any asset reference over the network
It's possible to do it. We just hadn't had the chance yet to implement it.
Can you describe to me how I would implement it? I was wanting to send some kind of unique identifier over the network which lets me easily look up the asset but I don't think this exists in Unity?
Look up the asset efficiently*
I'm wanting to avoid having to add all my scriptable objects to a list or some container and then look up the object in there.
register the objects in a list that the client and server share (at build time), deterministically generate ids for them and share those. have the sharing mechanism wrap the lookup and return the object instead of the id.
This needs to work in editor as well, is there an easy way to update this object every time a certain asset has been created/deleted?
that is up to you to implement
Sorry - I mean are there hooks for this in editor
If you want something efficient and without having to add them to a list one workflow would be to:
- Create a class wich derives from ScriptableObject e.g. NetworkScriptableObject
- Add a private ulong field to it and make it a serialize field
- In OnValidate assign the field the value of GlobalObjectId.GetGlobalObjectIdSlow(this)
- In Awake of the NetworkScriptableObject register the instance to a static dictionary using it's id.
Also this seems less than ideal. I would have thought Unity itself under the hood uses some mechanism/ID system for looking up assets anyways
You can check NetworkObject which does something very similar: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/develop/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
I'll go with that approach, sounds better. Why can't Prefabs spawned over the network work in a similar way?
Because the global object id stuff is editor only. You can't use it for runtime created objects.
Do you know why that's the case? Unique IDs for cooked assets sounds like an extremely useful engine feature nontheless
Yeah but you are expecting the server and the client to assign the same Unique ID to two separately instantiated objects.
Assigning the IDs at build time would fix that
you can trivially implement that yourself, it is not something every object needs and should therefore not be a default part of every object
Appreciate the help!
Yeah doing that for every object would not be what most people want.
and a network object already has a unique identifier
Unless I'm simply lacking knowledge of Unity's hooks, I would have to implement it using inheritance or composition or something purposeful. This is not a valid workflow for designers in my opinion. They shouldn't need to be thinking about these things
And there's an API for this actually but it will only work on actual assets
actual assets
Stuff in theResourcesfolder or in asset bundles?
unity is not as focused on a specific workflow and type of project as unreal is, you have to do some form of tooling yourself if you want to recreate a similarly designer centric experience as unreal provides
I guess I simple find the lack of APIs to do that frustrating. I can imagine no one has ever complained that you can address all assets in Unreal uniquely out of the box
But I digress
I have to set the asset as being addressable right? There's no overarching setting for it?
that even gives you extensive control over asset loading and memory
I actually made a script exactly for that, I can share if you want
I've got this script which is instantiated for every player on server just after they are logged in
The problem is with this line ```csharp
taskTexts = GameObject.FindGameObjectWithTag("TaskText").GetComponentsInChildren<TextMeshProUGUI>();
because for server it finds an object with tag "TaskText" but client is getting null reference exception
I'm using this code to spawn my players
public class GameManager : NetworkBehaviour {
[SerializeField] private GameObject playerPrefab;
[SerializeField] private Transform spawnTransform;
private List<PlayerSurvivor> playerSurvivors;
private PlayerAttacker attacker;
private void Start() {
if(!IsServer) {
return;
}
foreach(var client in NetworkManager.Singleton.ConnectedClientsList) {
SpawnPlayerServerRpc(client.ClientId);
}
}
[ServerRpc(RequireOwnership = false)]
private void SpawnPlayerServerRpc(ulong clientId) {
GameObject player = Instantiate(playerPrefab, spawnTransform.position, Quaternion.identity);
NetworkObject playerNetwork = player.GetComponent<NetworkObject>();
playerNetwork.SpawnAsPlayerObject(clientId);
}
}```
that object exists on client?
You mean taskTexts which are null for client?
These are on Scene
I don't know why server can reference this object but client doesn't
this is player code
Hey, I have a Hud element showing the playerhealth in multiplayer using mirror, but it just shows the HP of the last shot person, not my own, and i am unsure how to tell my Client that the Hud element should only display his local health https://pastebin.com/e1kXYuWb
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 you share it
Thanks
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.
it only looks for gameobject prefabs in Ressources but it could work with scritpable objects too
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;
public class OnClickFunction : MonoBehaviourPunCallbacks
{
public InputField playerName;
public Button playButton;
// Start is called before the first frame update
void Start()
{
playButton.interactable = false;
PhotonNetwork.ConnectUsingSettings();
PhotonNetwork.AutomaticallySyncScene = true;
}
public void Play()
{
string playerNameText = playerName.text;
PhotonNetwork.JoinRandomRoom();
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
RoomOptions roomOps = new RoomOptions();
roomOps.IsVisible = true;
roomOps.IsOpen = true;
PhotonNetwork.NickName = playerName.text;
string roomName = "Room" + Random.Range(0, 1000);
PhotonNetwork.CreateRoom(roomName, roomOps);
}
public override void OnJoinedRoom()
{
print("JoinedRoom");
}
}
Why isn't this printing joined room when I click the button?
@glass steeple I actually have been watching tutorials and trying really hard xD
But eventually i'll get it maybe
Btw its not erroring
Yes alr
Im calling play
Alr
Ill put a lot of prints
then come back
hmm
Fixed it was a clicking issue, lemme input the code now brb
lol
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;
public class ClickFunctionTest : MonoBehaviour
{
// Start is called before the first frame update
public InputField playerName;
public Button playButton;
public void BeenClickedAye()
{
print("BeenClicked!");
string playerNameText = playerName.text;
PhotonNetwork.JoinRandomRoom();
}
}
NullReferenceException: Object reference not set to an instance of an object
ClickFunctionTest.BeenClickedAye () (at Assets/ClickFunctionTest.cs:16)
UnityEngine.Events.InvokableCall.Invoke () (at <d3b66f0ad4e34a55b6ef91ab84878193>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <d3b66f0ad4e34a55b6ef91ab84878193>:0)
UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:68)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:110)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:262)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)
Dude I don't know what to do can you just send me a tutorial that you know of or something cuz i've searched for hours
did you set playerName to anything?
how did you get errors without running it?
wait
It auto errors sometimes
way
Of fixed
u were right it was accidently already running
lol
mbmb
now when I click it though ```d
JoinRandomRoom failed. Client is on MasterServer (must be Master Server for matchmaking) but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
UnityEngine.Debug:LogError (object)
Photon.Pun.PhotonNetwork:JoinRandomRoom (ExitGames.Client.Photon.Hashtable,byte,Photon.Realtime.MatchmakingMode,Photon.Realtime.TypedLobby,string,string[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1663)
Photon.Pun.PhotonNetwork:JoinRandomRoom () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1597)
ClickFunctionTest:BeenClickedAye () (at Assets/ClickFunctionTest.cs:17)
UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)
Damn it.. so like the issue is I guess the client hasn't even joined?
but like.. even if i add a wait it doesnt fix
You need to wait for OnConnectedToMaster before you try to do anything like room joining
@olive vessel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;
public class ClickFunctionTest : MonoBehaviour
{
// Start is called before the first frame update
public InputField playerName;
public Button playButton;
public bool HasConneted;
void OnConnectedToMaster ()
{
HasConneted = true;
}
public void BeenClickedAye()
{
if (HasConneted == true)
{
print("BeenClicked!");
string playerNameText = playerName.text;
PhotonNetwork.JoinRandomRoom();
}
}
}
So I think that will work lemme test 😛
It won't error
What o I put then if its not a callback?
Wrong method signature, wrong parent class
You really need a basic tutorial for PUN
This is like minute 1 of PUN
;_;
WhereERe do i find this magical tutorial
i have searched for hours
and hours
probably 6 hours today
I followed them
but like they all have errors and when i ask for help they all say gO loOok FOra TutORail
So now I'm just trying on my own
I think you're way out of your depth
Possibly but I'll still keep pushing cuz thats how you learn...
Do you have anywhere that I can find good tutorials
Dapper Dino and First Gear Games both have PUN tutorials on YouTube#
Connecting to master is one of the first things you actually do in PUN
Ok
I'll study and then come back
This channel is for science related videos focused on debunking the scientific claims of creationism. The videos are hosted by The Dapper Dino, a CGI Ceratosaurus created, animated (poorly), and voiced by one man using Blender Cycles.
I discuss topics such as evolution, creationism, evo devo, paleontology, comparative anatomy, and any other sc...
This dude?
Welcome to the channel. I'm here to introduce people to coding and give them the motivation and assistance that they need to start the projects that would otherwise never be conceived. Be sure to subscribe if you like what you see and I would highly recommend joining our Discord server to stay up to date with what's going on in our community and...
XD
fair
First Gear Games looks good
https://www.youtube.com/channel/UCGIF1XekJqHYIafvE7l0c2A @olive vessel This supports pun 2 right?
Game design company and educational resource.
FirstGearGames Discord: https://discord.gg/NqzSEqR
He has done PUN videos, you need to find them
Most new ones are his own netcode solution FishNet, before that it's Mirror. But I have seen some PUN stuff
find them
ht
hot
@olive vessel How do I delete something using pun but with a time variable, because pun doesn't accept time variables. Like with pun you can't do Destroy (whatever, 5); only Destroy(whatever).
Coroutines?
Aright
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class TestConnect : MonoBehaviourPunCallbacks
{
// Start is called before the first frame update
private void Start()
{
print("Connecting to server.");
PhotonNetwork.GameVersion = "0.0.1";
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
print("Connected to Server");
}
public override void OnDisconnected(DisconnectCause cause)
{
print("Disconnected from server for reason " + cause.ToString());
}
// Update is called once per frame
void Update()
{
}
}
So now I'm making a connect to server function
But the issue is its erroring
Assets\TestConnect.cs(20,41): error CS0246: The type or namespace name 'DisconnectCause' could not be found (are you missing a using directive or an assembly reference?)
I though this would already of been defined with pun
So like in this video
Become any tier member on my Patreon below for the source files!
Would you like to help me grow? There are a variety of ways you can support me here: http://firstgeargames.com/donate/
They dont define it anywhere, but what else am I supposted to define it as?
public override void OnDisconnected(DisconnectCause cause)
``` Is my issue line
DisconnectCause is in the namespace Photon.Realtime
You can see him add it actually
Note: A configured IDE will tell you this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MainMenu : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] private TMP_InputField nameInputField = null;
[SerializeField] private Button continueButton = null;
private const string PlayerPrefsNameKey = "playerName";
private void Start()
{
SetUpInputField();
}
private void SetUpInputField()
{
if (!playerName.HasKey(PlayerPrefsNameKey)) { return; }
string defaultName = PlayerPrefs.GetString(PlayerPrefsNameKey);
nameInputField.text = defaultName;
SetPlayerName(defaultName);
}
private void SetPlayerName(string name)
{
continueButton.interactable = !string.IsNullOrEmpty(name);
}
public void SavePlayerName()
{
string PlayerName = nameInputField.text;
PhotonNetwork.NickName = playerName;
PlayerPrefs.SetString(PlayerPrefsNameKey, playerName);
}
// Update is called once per frame
void Update()
{
}
}
First error: ```d
Assets\Scripts\MainMenu.cs(8,30): error CS0246: The type or namespace name 'TMP_InputField' could not be found (are you missing a using directive or an assembly reference?)
Second error: ```d
Assets\Scripts\MainMenu.cs(9,30): error CS0246: The type or namespace name 'Button' could not be found (are you missing a using directive or an assembly reference?)
What does it mean the type namespace? I'm making a new one...
Play & Vote On My Game Jam Entry: https://itch.io/jam/cgj/rate/476893
Just Here To Plug My Social Media Stuff:
https://www.patreon.com/dapperdino
https://www.twitch.tv/dapper_dino
https://twitter.com/dapperdino4
https://github.com/DapperDino
Create Your Photon Account Here: https://dashboard.photonengine.com/en-us/account/signin
This is the tutorial im following if anyone is wondering
you need to import the references, like how you imported system.collections and unityengine
Ah
sounds like your code editor isnt properly setup, it should be saying that in visual studio too
Yes I need help
#854851968446365696 Isn't helping
I keep following all the steps
But like nothing
But what do you mean import the references? In the tutorial it said nothing like that.. I'm confused..
You need to get that IDE sorted, it is beyond ridiculous
We've had this issue with you for at least a month now
I love this guy
Somehow has the courage to keep asking questions no matter what we say, still can't manage to read doc or do any of the things we suggest lol
2 months cough
Ok ima search for this "doc" you speak of
I have no clue were it is
And I Can't find it on the pun website, unless im looking in the wrong area
@glass steeple Could you send me link to doce?
Well for TMP issues, you should use their docs, they're not hard to Google
If you struggle to use the internet, you should find a class which teaches you how to use a search engine
What tmp issue
?
That I fixed I just took out the tmp lol
I didn't know what it even was used for
@olive vessel
But whats the docs everyone is talking about?
Yes
true
Where is the pun doc I've searched everywhere
I am going to have a heart attack
So rather than find out how to use TMP, you’d rather just not use it
This is why you shouldn’t be making a multiplayer game

Ok
Ok ok
Ill research wth a tmp is (:
TextMeshPro
So I'd probably have to put Using UnityEngine.TextMeshPro
At the start
for the text mesh pro to work
Wrong, just research it
It is not UnityEngine.TextMeshPro
well its close to it maybe?
Yes see
It says text mesh pro
Wdym its the first fucking result? Wait u mad at me or at google?
Why would I be mad at Google? It had the answer I wanted exactly where I expected it
Then why u mad at me xD, I said text mesh pro
And that is still not the namespace you needed
The namespace you would put into the script to use Text Mesh Pro, is not Text Mesh Pro, it can't even have spaces
@rotund badger honnestly tho, if you want to learn gamedev it's fine but you are certainly not ready for multiplayer
LETS GO I FIXED IT
😛
hell yeah
Where would you even find that link though
Like
It's called the internet
I searched, whatever, I mean I solved problem so thats pro i guess
😛
😛
XD ok i llstop
Dude wdym lazy
I'm legit not... I've been grinding all day to get something done
Im 13 bro lol
Im trying my best
Ill keep trying as well
You can't get rid of me yet xD
I feel like the docs are pretty easy to find. They are exactly where I expect them to be. Literally can be accessed from the main page
@rotund badger you have take a couple steps back and start from the beginning
learn the things and actually understand them before moving to the next thing
Find a basic unity introduction tutorial
play with the concepts it teaches
We've been through all this
actually try to understand
I know how to make a single player game...
I wont stop until I make a multiplayer game that I can play with the boys at school (:
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!
Still grinding
Learning everything
Sleep is a reccomendation nerds
cant figure it out
just wasted 8 hours maybe
but whatever lol
ima sleep peace
Because you are trying to take too many big steps
Start small and simple
Go back to the beginning
So I am thinking of a way to update positions on all other entities around one entity, question is what way would you prefer and why?
- For each player, fetch all network entities around him and send him the positions in a list
- For each network entity fetch the position (update) and send to all players around the network entity
And then send one packet to the player with the list anytime something updates?
Yeah
Hi so I am currently making my first multiplayer game, and I am currently working on the movement system, however Unity doesn't seem to pick up the rigidbody that my instantiated player has on the server side, I'm sending the player input to the server which needs to process it and send the new position back to the player but it can't find the player's rigidbody, it does have one in the inspector so I'm not sure what the problem could be. The test I did:
Debug.Log(rb.transform.position);
the error:
NullReferenceException: Object reference not set to an instance of an object
PlayerMovement.MyInput () (at Assets/PlayerMovement.cs:94)
PlayerMovement.MovePlayer (System.UInt16 PlayerInput, RiptideNetworking.Message playerInput) (at Assets/PlayerMovement.cs:79)
RiptideNetworking.Server.OnMessageReceived (System.Object s, RiptideNetworking.ServerMessageReceivedEventArgs e) (at <6fc295986c534e3fb691cbb0a3648ff3>:0)
RiptideNetworking.Transports.RudpTransport.RudpServer.OnMessageReceived (RiptideNetworking.ServerMessageReceivedEventArgs e) (at <6fc295986c534e3fb691cbb0a3648ff3>:0)
RiptideNetworking.Transports.RudpTransport.RudpServer+<>c__DisplayClass37_0.<Handle>b__0 () (at <6fc295986c534e3fb691cbb0a3648ff3>:0)
@wispy bobcat can you show us the surrounding lines of code of PlayerMovement.cs:94?
Right, so here's that section:
public void MyInput()
{
x = Input.GetAxisRaw("Horizontal");
y = Input.GetAxisRaw("Vertical");
jumping = Inputs_[0];
crouching = Inputs_[7];
Debug.Log(rb.transform.position);
//Crouching
if (Inputs_[5])
StartCrouch();
if (Inputs_[6])
StopCrouch();
}
I'm rewriting my single player code so there's still a lot left from that - this function get's called every time the client sends it's inputs to the server which it does in an array, the rb comes from an instantiation which gets called when the player joins the server
Player player = Instantiate(GameLogic.Singleton.PlayerPrefab, new Vector3(0f, 1f, 0f), Quaternion.identity).GetComponent<Player>();
I can also show you the instantiated player in the editor if you want
it's not just that one line tho, it's everything that has the rigidbody in it
What line is line 94?
Debug.Log(rb.transform.position);
Ok, rb is a public member which you assign in the inspector?
The rb is a component on the player that gets instantiated
void Awake()
{
rb = GetComponent<Rigidbody>();
}
oh wait
maybe it's because it's on void awake and the player isn't there yet when the game launches?
Can someone tell me or give me a hint why the Clients are moving faster than the host? ```cs
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveX, 0,moveZ);
Vector3 curr_position = transform.position;
Vector3 targetPosition = curr_position + movement * 5 * Time.deltaTime;
Debug.Log(targetPosition.ToString());
rb.MovePosition(targetPosition);
Both are essentially the same object with a networktransform using mirror
ah I just changed it to
void CheckRb()
{
rb = GetComponent<Rigidbody>();
Debug.Log(rb);
}
and now it's saying:
NullReferenceException
UnityEngine.Component.GetComponent[T] () (at <028e4d71153d4ed5ac6bee0dfc08aa3b>:0)
though the rigidbody that im referring to is defo there because when I instantiate the new player and click on it the correct rigidbody is in the slot
I am gettting this error when I try to call a PlayFab function on my server build. An unreal dev told me that there is a flag called Verify Peer that verifies all SSL connections. Is there an equivalent solution to unity?
sudo
let me know if it worked for you, maybe I'll package it in a nicer format
Is there any recommended courses for .net networking in unity? Would it be better if I found something specific for .net and just try to implement it in unity? The general APIs for networking in unity haven't seemed ideal for what I'm looking for
what do you mean by .net networking? what do you want to do?
I won't actually be using it since I found a different solution that I like more but thank you!
what did you find?
I meant using .net sockets to create an online multiplayer game and send information from servers to clients
this is some theory on common multiplayer netcode problems and solutions #archived-code-advanced message
beyond that you're best off looking at examples and working implementations of netcode. Tutorials/courses cannot teach the complexities of actual, real world impelentations. Reading the source code of mirror and netcode for gameobjects is also a great way to start before writing your own. unless you are well versed in multiplayer networking i would not try to write a transport layer myself, there are excellent implementations out there already (enet, LiteNetLib, Lidgren, Ruffles, Telepathy, KCP...)
this is not working
what return type?
because this works, but not for me?
you need to specify the proper return type, which seems to be void in this case :)
np
Can someone tell me or give me a hint why the Clients are moving faster than the host?
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveX, 0,moveZ);
Vector3 curr_position = transform.position;
Vector3 targetPosition = curr_position + movement * 5 * Time.deltaTime;
Debug.Log(targetPosition.ToString());
rb.MovePosition(targetPosition);
Hi guys how do i add online multiplayer to my game
heelp, anybody with uMMO ?
does it local multiplayer are their default or we need to do a little adjustment ?
Pretty sure host mode is included, which is essentially the same thing. I imagine people on their discord would confirm that for you.
Oh did you mean like multiple players on the same device?
the server address seems created yet
support think this is too basic, while the docs are unclear
Still not sure what you are trying to do
the game seems need Localhost IP LAN
How client can get reference to a scene object in Start method?
I am trying to do this by using GameObject.Find() and I get NullReferenceException
So, I'm using mirror and this function in my code is causing the error: 'Disconnecting connId=0 to prevent exploits from an Exception in MessageHandler: ArgumentNullException Value cannot be null. Parameter name: key', this function is causing it, but I have no idea why. (items is a SyncDictionary<Item, int>):
public void CmdAddItemToItems(Item item, int amount)
{
if (items.ContainsKey(item))
{
items[item] += amount;
} else
{
items.Add(item, amount);
}
}```
the item you pass into the method is null. you have to figure out why that is and fix that. this code is not the cause of the issue, its the point where the failure occurs.
I thought that PhotonNetwork.Destroy(viewID.gameobject) would destroy a gameobj for everybody, is this wrong ?
Hey folk!
(NetCode For GameObjects) how can I get a new joining player's Player asset?
the network players id list is only saved on the host, is there a way to get the body of a player through their id? or get it the second they join?
Can someone tell me or give me a hint why the Clients are moving faster than the host? The players are just cubes with rigidbodys attached, and they each have a Networktransform using Mirror
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveX, 0,moveZ);
Vector3 curr_position = transform.position;
Vector3 targetPosition = curr_position + movement * 5 * Time.deltaTime;
Debug.Log(targetPosition.ToString());
rb.MovePosition(targetPosition);```
Anyone use Pun?
@meager crypt Don't ask to ask. #854851968446365696
Ah sorry
Im using pun and I Instantiate, and then parent the GameObject which works with with the client. However, when another player joins the instantiated object is in the wrong place. What could cause this?
The reparenting is not automatically synchronized in PUN. You need some way to let new players know the new hierarchy.
It does.
any good network solution for unity 2021+ except steam api? I wanna do like player-host and players-clients but also i want to do lobby list. In pun 2 server list is very easy, but i cant figure out how to make player host server, but not to use photon's servers.
Does anyone have a clue why a game object with a rigidbody would move faster when you are the client?
(Mirror)
Good afternoon. How does all this differentiation of realms work? For example, I create a method and give it the Command attribute. What now happens when I call it in the game code? Does it check where it is called from and if it is called from the client, does it send a request to the server? What is the general feature of this method, unlike others?
it is used for calling a method on the client that is actually executed on the server. A ClientRPC does the inverse, called on the server, executed on the client. Other methods are executed where they are called.
Okay. This is rpcs, right?
But my client have this method too. Why when I calling command method I executing this method on server?
Then when I calling method with Command attribute mirror checking who am I and doing something?
If client then gets connection and sends rpc
Or If I host then just calling this function
If you don't understand something from my words please tell me and I will start use translater👍
More or less, yes
Okay. If I change something on server then I should sync this or It will sync automatically?
That’s basically what mirror is all about… sending high frequency data with low latency and enabling you to run methods on another computer over the network.
And what about Server/Client attributes. How to use it and for what I can use it?
Oh. Okay
How to understand server-only or client-only parts? Code anyway exists on all realms?
those can be used to make sure that method is only called on the server or client
Yes code exists on all instances. Whatever makes something the server is decided by the mode you launch it in
For making the compiler/runtime enforce your own ideas about what should run where
What will happen if I just call ClientRpc from client
An exception
Okay. How I understand:
Server is just central point that can make some changes and sync this changes with client. But how this splitting?
Server know about all gameobjects in current scene, right?
Yes, if they are networkobjects
Server know only about network objects?
Oh. Then server have his own c-side objects
If it is a host, yes
Host is pair client - server
Yes?
Oh okay. Thank you
And one thing..
If server know only about network objects then I can't just move piece of wall on client?
Only if wall is network object
Because wall is client side map
Just I think what server should know about loaded scene
The server knows about scenes and will assume they are identical with its own. But it can’t know for sure
If a client spawns any non network objects, the server will not automatically know about them
Okay. Thank you! You really helped me to understand how it works
Hello!
@charred dock So, what I need its basically having a console that do some math and sends the result back to Unity
like
Unity sends to the server:
ExampleArray[1,2,0,0]
the server takes this array and for example multiply those numbers
and give the results back to the Unity
2
in this case, the client/player will get the result
So the best way I can think is to create an server build with the functions needed for the math problem and do an RPC with that array and have it return by doing an another callback to the client
hmmm
like, the thing its that what I think that I need its a console running and getting those inputs from the client
in this case, the console will be created like a room inside of the server
when a "battle" starts
@jolly tree what's your goal in doing this?
Why does it needs to be a console?
why couldn't the client do the operations?
@glass steeple I was about to ask that, I am still confuse on what he is asking
Its because the game needs to be secure
ok sure
we gonna work with and stuffs like that
I'm not sure.
So not really than huh
I feel like if you ask such basic questions you don't have the skills to get involved with blockchains lol
You'd need to be a least a little familiar with networking and stuff like REST API?
this is the reason why I came here to ask for help lol
What kind of blockchain are we talking? Just communicating with some online service?
I don't think those problems are really related to Unity
damn I cant talk too much about this, but its basically saying to server "hey I want to do this" and the server verify if I can, and if I can, the server do this
will be like a mirror
all math, processing and those kind of stuffs needs to be in server
what I found its PUN but PUN create a master and math happens in user-side
so I cant use it
I'm start to think that I need to create it from scratch
and damn...
you could use Mirror
That's what I use and it works well
you have some code that runs on the server and some code that runs on the client
yeah but the problem is code running on the client-side
what's the problem with it?
well how could they, that code should run on the server
But I dont know what kind of technology use
okeh
Look into Mirror
you could, like, google it?
btw, thanks for your time, now I have an abstraction of a north
basically you put all the code you need to be trusted on the server
on the client rather then saying "damage this player with 1000" you say, "run the attack command"
And the server checks if you can use that thing right now, then it does the damage etc and sends it to all clients
Yes
exactly what I want
but the first thing that I need to know its figure out how to do this in Photon
why do you want to use Photon?
I don't even clearly understand what Photon is
IDK D:
They said that they pretend to use Photon
do you know any other technology that could be more efficient?
and easier to learn
Okay! I will read about this
but, you think that is sufficiently secure?
like... we gonna put hands on fire
depends on your implementation but I don't see why it wouldn't be
okeh
except with your 0 amount of experience I really wouldn't trust it
huaehauehaueh
thank you for your time, Lapinozz
I will start learning about this right now
good luck
Why not? The engineers of photon sit in this discord
Sure
what do you mean sure
Not very practical for dedicated server no?
Hi how can I add local multiplayer to my game using Mirror and have a player count ?
BTW I am a VERY big beginner
Hey folk!
I have a Web API project and want to make provisioning for different environments.
Do I have to build CI/CD pipeline with 3 branches in Git or is there another way?
If the task is to make the server do some calculations (not move some objects in a Unity scene), then a Photon Server would likely be more efficient, really. You don't have to run Unity headless on your machines, if you don't need the engine.
It really depends on the requirements, which we don't know.
Actually, a secure web request can do what he was asking for, as long as it's not related to a scene.
Code in Command method should be runned on serverside?
Tbh I haven't looked that deep into photon, I don't like the pricing model
Man I wish there were more dedicated program server tutorials
And not dedicated "host it on this paid platform" server tutorials
Which part are you having trouble with?
Unity's new multiplayer api
Not sure what you're supposed to use yet
And really hesitant to switch from legacy tbh
You can build a dedicated server, but from forum thread it's not a good idea
why it's not a good idea?
People report crashes, failed builds for no reason, weird bugs, platform specific issues
As recent as last week
It's apparently a super early version of dedicated build feature
Yes thinking this or liteLib
I worked with mirror once and it wasn't bad tbh
I'm using it right now but I'm just sending NetworkMessage directly
Yeah don't wanna get into super high level stuff either
And LiteNetLib is just a udp library anyway
Mirror has already all the client/server/host logic so that's nice
and you can use multiple transport
So it's a bit nicer than using udp directly
what's the difference?
Bare minimum code and no assets?
ah
Like, correct me if I'm wrong but headless is just building a game and running it with no graphics
To act as a server
And dedicated is an app that just handles server things
ah yeah
I mean
you can do a Server build and it shouldn't include any visual stuff
and use #if UNITY_SERVER or something if you want to strip down on the code
Yeah Unity are trying to automate this but rn it seems like trash
Probably? From user reception
just ticking the box
Dedicated server build?
the "Server Build" in the build options
which version of unity are you on?
but I think dedicated servers work starting from any 2021
the Server Build option
Yeah and that new solution is supposed to just
Find network code and remove anything else?
I think
how does that work lol
bruh
misleading
I though it was something like removing unused code compiler optimizations
ok writing a server manually then screw this
outside of unity?
lol good luck
Wouldn't be very feasible for me as my game relies heavily on physics and stuf
which is the simplest way to make a post request from unity to server?
public static async Task<string> Login()
{
const string url = HOST + "/auth/login";
WWWForm form = new WWWForm();
form.AddField("email", "email");
form.AddField("password", "password");
UnityWebRequest webRequest = UnityWebRequest.Post(url, form);
await webRequest.SendWebRequest();
Debug.Log(webRequest.error);
string a = System.Text.Encoding.UTF8.GetString(webRequest.downloadHandler.data);
string data = JsonUtility.FromJson<string>(a);
return data;
}
private async void Start()
{
string a = await Login();
print(a);
}
the webrequest here return that the server cannot understand the request with status 400
maybe because I use WWForm, and the server is expecting a json_data
json_data = request.get_json(force=True)
the server is python flask
I think it would expect just raw json in the data
yes, it does. but how to send that from unity?
I should write something like that?
IEnumerator PostRequest(string url, string json)
{
var uwr = new UnityWebRequest(url, "POST");
byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(json);
uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend);
uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
uwr.SetRequestHeader("Content-Type", "application/json");
//Send the request then wait here until it returns
yield return uwr.SendWebRequest();
if (uwr.isNetworkError)
{
Debug.Log("Error While Sending: " + uwr.error);
}
else
{
Debug.Log("Received: " + uwr.downloadHandler.text);
}
}
it's working!
May I use the same code but with async await instead of coroutines?
I already tried, and uwr.SendWebRequest() cannot be awaited. Where should I look for the equivalent awaitable?
Does Photon Cloud exist? Something that runs server in cloud and Unity communicates with it
is this better? it's not async but uses event, I don't know if there is a pitfall on adding listener without removes
private void PostRequestV2(string url, string json)
{
var uwr = new UnityWebRequest(url, "POST");
byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(json);
uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend);
uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
uwr.SetRequestHeader("Content-Type", "application/json");
//Send the request then wait here until it returns
UnityWebRequestAsyncOperation a = uwr.SendWebRequest();
a.completed += (b) => AOncompleted(uwr);
}
private void AOncompleted(UnityWebRequest uwr)
{
if (uwr.result == UnityWebRequest.Result.Success)
{
Debug.Log("Received: " + uwr.downloadHandler.text);
LoginResponseData loginResponseData = JsonUtility.FromJson<LoginResponseData>(uwr.downloadHandler.text);
Debug.Log(loginResponseData.user);
}
else
{
Debug.Log("Error While Sending: " + uwr.error);
}
}
(Netcode) can someone please send an example of networkDictionary?
Wasn't NetworkDictionary removed?
never heard about that
what should I use instead?
There's NetworkList but you don't get a Key Value thing then
that may work, thank you!!!
Anyone have a good client side prediction solution for mirror
I have a non-Unity bot streaming System.Numerics.Vector3s into my Unity client at a steady rate (roughly 60 fps). What is the most efficient way to convert it to UnityEngine.Vector3 once it hits the client? Currently constructing a new UnityEngine.Vector3(packet’s System.Numerics.Vector3.x, y,z) upon receiving the packet in the Unity client, but I am wondering if there is a more efficient way.
Pretty sure that's the go-to way of doing stuff like that
vector3s are pretty fast to create anyways since they're just structs
Thanks. I did read that modifying a default vector3 is slightly more efficient than constructing a new one, but they both seem acceptable for what I’m doing
my vector 3's get split up into 3 floats when sending it over a network and then I just reconstruct it on the other end
nope
but i do recommend you use riptide by tom weiland
he made a tutorial of how to use it but its actually not that hard
its pretty awesome
How to make synced property?
I created abstract class from what should be inherited all door switchers
But in children class I can't make this property synced
I want:
-Server instances automatically being hosted in playfab,
-Clients using playfab to figure out the servers ip,
-game server simulating the game and scoring the players when the game is finished
What sort of a photon realtime setup should I be doing here?
A few yes, better to ask and assume some might wander by!
[Netcode for GameObjects]
How client can get reference to scene object just after it instantiates? When i'm trying to do this in player script (in method Start() ) by GameObject.FindGameObjectWithTag() client gets NullReferenceException but server finds it correctly.
i know i mean if you really want your code to work exactly how you want it to just use something like riptide and if you want to use photon like you said blackthornprod made a video about that
is that free?
oh nice
!ban 911573495908032552 Annoying guerilla advertizement.
Akarsh jain#1773 was banned
Follow the object it points to to find the copy
I have two objects with same class
FirstKeypad and copy of FirstKeypad
I have many doors. In any door I have FirstKeypad and SecondKeypad
When I delete SecondKeypad this working
If I spawning more than one door this returns exception....
What...
The error is telling you that you can only have one
But why
And the reason why
This is nonsense
Why I can't copy this objects
Hm
I need more doors than one
How to separate this entities?
Then why when I spawning many players this don't returning errors?
(Photon PUN 2) first time with network events - I am trying to send a network event to destroy a bullet. However my photonEvent.code is not consistent. I am trying to sent a const byte 0 in my RaiseEvent but is not always 0 and therefore my bullets sometimes do not destroy themselves. Could someone please explain what I am not understanding? https://www.toptal.com/developers/hastebin/agozicayaz.csharp
Has any one worked with riptide for networking?
OnEvent will catch all events, so event code not always being the one you are looking for is expected. I would make sure that event code 0 is not reserved for something specific.
The players probably aren't scene objects. I don't think most networking solutions expect you to be cloning scene objects and instead expect you to use prefabs.
Yup - found out but alls good now thx
But my doors is prefabs
I anyway see this error
Do anyone has any idea about an easy networking solution that does server authoritative movement for me with 0 cost?
?
But are you cloning something that already exists in the world? Scene objects are already spawned, unlike actual prefabs.
But how I should create door system If I can't copy prefabs....
You can copy prefabs, but not scene objects
No
What are you referencing when you are instantiating those doors?
The door in the scene or the door in your project files
When I instantiating I referencing to door in project files
I think
Well considering the error, you should probably know rather than guess 😄
Oh then to object on scene
But I don't understand how I should fix this error
If I can't duplicate this objects on scene then how I should create more door than one
Make more using the prefab
Create a public door field in wherever you are spawning those doors from and drag in the prefab from project files
I don't understand
I should spawning doors in needed positions using code?
Depends on the situation, either way is fine
Scene objects you generally just can place in the scene
But if you need more at runtime, then sure, spawn more
But stop
May be I don't understand your words above
You said that I should create a public field containing a door.
If you wanted to spawn a prefab, generally yes
Okay and what I should do with this field in next?
Spawn doors whenever when I need?
Using script
What do you mean by this field in next? I don't know the situation
I have static map
Then I would just place them in the editor
In every room should be one door
But this calling error
So you aren't spawning new doors at runtime?
No
As in you don't have code creating new doors
In that case I would go to the Mirror discord to figure out why your scene objects are behaving like this. Clarify upfront that you are not instantiating new objects.
hey everyone i just started using the unity multiplayer SDK and the first code that i run in my game is await UnityServices.InitializeAsync(); and when it runs i get the error of "Failed to load config from cache"
this is what unity documentation says as the first thing i should run ti initialize unity service
Does anyone know a good tutorial Series on how to setup multiplayer in unity? I am making a simple quiz game, and i want for the Player to be able to host its own Server, on mobile, but i dont know how to do it
You can find resources pinned in this channel. There are also third party solutions like Mirror and Photon and others, they have own tutorials.
Im currently trying to learn some basics about the new unity networking implementation "Netcode for gameObjects".
(Currently following the Golden Path Module 2 tutorial)
So my question would be: how would i declare a networked variable that is owned by the server? (and cant be overwritten by clients)
Something like:
public NetworkVariable<Vector3> Position = new NetworkVariable<Vector3>();
about unity.transport package,
i think there is a limit on the number of data that can be send in one frame.
Is that true? and if so whats the limit?
simply put yes
Hey guys is there actually any code example on how to do Client Side prediction in Netcode for gameobjects?
Hi, I see others characters flicker when running in the same direction
I'm syncing with photon transform view
Using the new Unity Netcode for GameObjects package (which is in pre release) and wondering why that "OnFailedToConnect" callback wont get triggered after failing to connect a client via "Singelton.StartClient();"
using UnityEngine;
using Unity.Netcode;
using Unity.Netcode.Transports.UNET;
public void JoinServer()
{
NetworkManager.Singleton.StartClient();
}
// The Callback
private void OnFailedToConnect()
{
Debug.Log("Failed to connect to server");
}
Where does that callback come from?
Well im guessing its from the UNET transport
i havent found documentation on that so
I have never seen it before
It might be deprecated
But i need some kind of callback in order to check if the connection failed
those are the old unet callbacks that used reflection, yea they dont work anymore
you should read the mlapi docs and figure out where their callback is
Yes it does but I heard that the webgl transport isn't maintained, so might not be up to date
How to sync transform without jittering?
hey anyone interested in participating in a gj??
The theory of it is here https://www.gabrielgambetta.com/client-side-prediction-server-reconciliation.html
Why client can't find a scene object in OnNetworkSpawn() or Start() but in Update() method it is able to find it only after 5th frame?
loopCount variable is to check on which frame taskManager is found and it's always 5 when it should be 1
Hi, i need help with networking. Im working on a multiplayer fps game for the first time and im very confused.. i searched for the documentations in unity website but i dont know where to begin with. Unet, photon, netcode, im very confused. can someone please let me know what i should be doing?
Take a look at https://mirror-networking.com/
Relatively easy to get starter with, are some tutorials on YouTube aswell
This looks very cool, thank you kindly for sharing
Same here I’m still not sure what to do for networking???? 🤔
Research your options. Pick one. Start doing your project. Fail. Learn from it. Repeat. You generally can’t go wrong with any of the unity network libraries. If you have to rely on tutorials to get stuff done, networking will be a road filled with frustration, so set your expectations accordingly.
Thx for the help. And out of curiosity what do you think of unity’s new net code there working on?
It is easy enough to get working given the tutorials they have, however it looks as though I'd have to rewrite all of my scripts
Looks like I won't be talking to anyone over at the mirror networking discord haha
I can give you a role in the mirror server to bypass phone verify. just let me know, we only have that so that bots are deterred
Kindly do so, thank you
done
Thanks, those phonewalls are woeful
I want use interface for network object
Did I do it right?
Idk why but I can't make property synced var
how could i make a player respawn? using photon
i need someone or help with multiplayer in unity without port forwarding. it has to be server side because of cheating
if you have a server why wouldn't your forward the ports?
With Photon, how can I limit the max players in a photon lobby?
what version of photon?
Using MLAPI - how do I replicate a string?
where when what
Are you responding to me?
yes
I want NetworkVariable<string> which is not possible due to string being managed. What's the next best thing I can do?
You can do NetworkVariable<FixedString32Bytes>
aw that's unfortunate
https://docs-multiplayer.unity3d.com/docs/0.1.0/api/MLAPI.NetworkVariable.NetworkVariableString/index.html ah this is very out of date I see
A NetworkVariable that holds strings and support serialization
This is from 0.1.0
Do you know why it was removed? I see a lot of the built in NetworkVariables for more complex types, like Dictionaries, were removed
efficiency, avoiding garbage, coaching people to architect their netcode better (realtime netcode is not meant/optimized for transfer of variable length messages)
EDIT; removed, dumb/unlogic question.
Better formulated:
I am new and don't know where to start when it comes to structuring a game server, that can handle up to 300 players with larger open world (kind of as in games like RUST, or smaller MMORPGs).
start by building something that can handle 5 players and work your way up.
besides your suggestion which i will follow, i dont know where to start when it comes to accounting. I put all the code for database and such in unity? Or has unity an API for this? Can i run separate SQL database or does unity has inbuilt database functionality?
you don't put code into unity, you just access the unity engine with your code, just like you would access any other system like a database.
There is a difference between shippable netcode and prototype netcode. Expecting all netcode to be shippable is ridiculous
Those classes should exist as a prototype foundation
I mean you were given a solution, you can use strings, but go off
why does your prototype need more features than your "shipped" product?
that said, unity does not include a database, you would have to pick one that suits your game's design, the same goes for almost everything else about your project if you aim at that many players.
Because in normal professional game development you prototype constantly and then when you land on a design/solution, you optimize. You want the prototyping speed to be quick because your designers are quickly iterating and trying ideas
My initial question was directed at Luke out of curiosity
Thanks a lot, this (and the answer before) was exactly the information i was looking for! Thanks✌️
Hey guys, I'm making a session based multiplayer game using mirror networking. my questions is very general. I want to create a lobby joining system that allows the user to host a lobby, and then anyone else can join it by entering its generated code. now how should I approach this? the ways im currently thinking is the following:
Option A:
Make a scene called "Main Server" where all people who host lobby must connect to and pass their IP, then load another scene where they are hosting the session. later on when a player wants to join the lobby, connects to the Main Server, which finds if lobby with code provided exists and returns its IP for the player to load another scene where he connects to that IP. (The Main Server would run on a fixed computer to keep the game matchmaking system up and running, and its IP would be fixed in the code).
Option B:
Similar to option A but instead of having a Main Server, I use a cloud database like Firebase to store IP addresses and then the users read from that.
Is there an easier way to make this? I wouldn't mind paying for a service to handle the "Main Server" functionality if they provide it.
Why is client able to find other scene objects only after a few frames? It seems like it has some delay but I would like to put reference logic in Start() method without getting NullReferenceException error. I am using ParrelSync to test game.
Loop count is often 4 or 5 displayed in Debug.Log
🌟 Hello from Unity! 🌟
If you're working in multiplayer, please consider participating in this short survey. This survey asks what is meaningful to you in terms of the performance characteristics of multiplayer networking solutions. It also asks for your feedback on netcode-related terminology, including category names and wording in group-related concepts. The survey might take 15 minutes total to complete, if all questions are answered.
Survey Link https://unitysoftware.co1.qualtrics.com/jfe/form/SV_8HRRikgpVzfomhw
Unity Multiplayer would like to know your opinion on multiplayer networking performance and terminology. Have your voice heard and influence our direction!
Quick question Im using unity’s netcode thing we’re should I put the player camera. I know I want it on the client so I’m guessing I shouldn’t put a netcode object in it?
only stuff that needs to be the same on all clients and the server should be a netobject
your camera is likely different for each client, so its not part of a netobject. You also probably do not want multiple cameras in your client-scene for each connected client.
Thx
@austere yacht following my question from yesterday, one point remains still unclear to me; the server, does it have to graphically spawn and render the world to act as server? or can it be headless without graphics?
can be headless
there is a special build option for that
ah ok, thanks! i see planing multiplayer feature is more complex than i first thought. Besides the above question, some side questions arise, i.e. not sure if i need load balancing for more than 100 players, shall i use unity MLPA or Photon, and questions like that where i currently search the internet for information. But the main question about headless was solved, thanks for clarifying this 🙂
if you want all players in the same world, there is no load balancing, only controlling network visibility and reducing the amount of data that needs to be passed around.
Thank you, thank god i can get rid of load balancing. For data exchange, i'd probably go for JSON and exchange position and inventory data for the begin.
Thanks to your help, the image slowly becomes more clear on how i'd structure and layout a multiplayer game
if you want to study some theory: #archived-code-advanced message
Thanks a lot, i will check this out 🙂
which framework should I use for a multiplayer game? Photon seems cool, but 20 players for free ain't worth it. People suggested Mirror, but I'm not sure of it's limitations
I'm looking for less than 100 players for free. What options do I have?
You pay $95 you get 100 players on photon iirc @mossy kettle
for the year*
which framework depends on your game though.
My game is an fps.
Hi, where can I find some nice tutorials about multiplayer? I had a little experience with client-server in Java, but I don't know where to start with unity
There are many systems you can use, Unity's new official one is called Netcode for GameObjects, then there's community lead ones like Mirror and Photon. Photon is a company that has many different systems you could use like PUN or Fusion.
Any suggestions on which system should I use?
I like Mirror, but you should look into each of those and see which one fits what you want the best
I was trying to follow this guide https://docs-multiplayer.unity3d.com/docs/tutorials/helloworld/helloworldtwo, but I can't understand how to "host" the game using a vps... Maybe I should use Mirror?
using Unity's Netcode you make a user host a game, but I'd like to make user connect to my vps when the game starts because I need a matchmaking system
Netcode and Mirror are similar in this regard, both require you to either host servers, let players host servers, or use P2P
I'm fine with letting players host servers, as long as I have more clients than what photon provides for free
how many clients can I have by using Mirror?
How many can you fit before it crashes?
They've done some CCU tests with hundreds of clients
I want to create multiple lobby like pubg matchmaking lobby. which api i should looked in
ah got it. so the host client must be able to process everything that server is supposed to do. more code, more ram, more lag.
im not aiming for 100+ cuz its just a hobby project
with a coder friend
Has anyone here used Photon networking with Unity's FPS template? I get camera rotation latency only in builds, I think it has something to do with the cinemachine component but I dont quite understand why
Hi, I'm reaching out to anyone who's used the AWS (Amazon Web Services) SDK for Lambda.
I'm trying to simply invoke a function but get an empty payload.
If anyone has experience in this at all, help would be greatly appreciated, Cheers.
Here's my StackOverflow post for more info:
https://stackoverflow.com/questions/70982161/payload-is-empty-when-using-iamazonlambda-invokeasync-in-the-aws-net-sdk
If code base same on client and on server then why from the client the request is sent not by the client version of Player but by Input?
In that model, I think the game physics and updates act on the Player in in the server (to save time/ for security). All you need is the input from client.
Client side doesn't update the "player".
But why?
On clientisde I have my own player object
And I can change it
But if you allow all your clients to change the player object themselves, they can just hack and cheat through the entire game with just a little bit of coding.
I about rpc
Player have player object on clientside
And when on client something calling in player object Command function
Player object calling this function on server
Speed is a reason. Sometimes the client does not have the computing resources necessary to compute/update the player object quickly.
So instead of computing locally, computation is handled on the server
But anyway I calling function on clientside version of Player
How it works?
I calling function on client and this function through NetworkConnection calling same function on server?
Kinda. You can call the function on client, but client doesn't really do any of the computation. That computation is done by the server.
I undestand
But when I calling function on client, client should send request to server
Right?
Yep, I would assume so
Here's more in-depth
Sure one sec
https://www.techtarget.com/searchapparchitecture/definition/Remote-Procedure-Call-RPC
Scroll down to see the part I screenshot
There's a local procedure call > parameters/inputs are packed (marshalled) into a message > message is sent from client to server > server receives message > server unpacks parameters (unmarshalling) > ...
... > server procedure acts on inputs, computes return values/updates player, and packs the return values/objects into a message > message is sent back to client
And then client unpacks messages and uses the return values to update objects on client side
I can't import MLAPI using package manager (installing from git url) with 2019.4.2f1
Furthermore git from CLI throws "repo not found"
Hm...
Then what happening when I calling it?
When I calling it my client send request to server and server running this method on serverside
Right?
MLAPI is now "Netcode for GameObjects", perhaps that's the issue?
Anyone heard of or tried Fishnet networking? Everyone’s Ive talked too has said it’s amazing but considering it has only been out a couple months, I have my doubts
have they said why it is amazing?
I would recommend mirror or if you are making an fps or anything that needs prediction/reconciliation then go with photon fusion (or quantum if you have the money), all of which have been out alot longer than fishnet and have bigger communities to help you learn them
FN developer is also banned from this discord for discriminatory remarks and making alt accounts to advertise, not sure if that's something anyone would want to support, but as always, just use whatever works best for you
Pretty much what cooper said... while it (FN) is touted to be better than other network stacks (the dev has a lot of beef with the Mirror devs for some reason...) there has been no games made with that said stack, while Mirror et al have been proven to be able to provide you with fundamentals to make a successful network game. Mirror is focused on MMO-based games, but it is mature enough to be utilized for other genres. If you are trying to make a FPS in the style of Call of Duty or Valorant or Tarkov, then if you have the money go with Fusion and/or Quantum, they are battle tested.
See also: Mirage. It's a rolling-release network stack that originally started out as a close sister to Mirror, but has since evolved over time. While it's still a distant sister network library to Mirror, it incorporates features that Mirror can't/won't accept and also provides a modular framework - instead of using all of Mirage at once, you can piecemeal the setup to tailor to your needs.
Honestly, do your homework and pick your poison. Don't just jump into a network library because "omg omg features" and find that it's not ideal for your needs.
Personally, I started with Mirror then migrated to Mirage. I still have Mirror projects that are in the freezer for other reasons outside of networking libraries. Then again I'm making a shooter that'll probably hit a niche market. Need to check out Fusion though, I should have done that last christmas but I didn't
Is everyone you've talked to the same person (ie. the creator but using different accounts 👀 )
Hi, am I missing something? https://docs-multiplayer.unity3d.com/docs/basics/networkvariable/
At a high level, a NetworkVariable is a variable with its value tracked by the SDK. Its values are replicated to other nodes in your network regularly. When a client connects initially to a host, all relevant NetworkVariable latest values "state" will be replicated to that new client. Your state gets updated at regular intervals.
Is the documentation outdated or something?
How to use TargetRpc?
How it works?
I added target parameter in method
But I never use it
How mirror understand who should receive this rpc?
If the first parameter of your TargetRpc method is a NetworkConnection then that's the connection that will receive the message regardless of context.
If the first parameter is any other type, then the owner client of the object with the script containing your TargetRpc will receive the message.
https://mirror-networking.gitbook.io/docs/guides/communications/remote-actions
Read the fine manual... it's there for a reason and it will help you a lot 🙂
I about internal work
which editor is it?
Should I use Photon or Mirror for a Jackbox type game? (PC Screen is the game and all clients connect with a phone app)
either will work perfectly fine for that type of game, you can use mirror with EOS transport for free relay and not pay anything (as apposed to paying for photon relay)
you can also just use mirror normally with default transport if you just want local play only
im just following a tutorial on youtube and there's an error im getting
this is the error im getting
No namespace at the top?
I have given it... Using Photon.pun
yea but you need to enter the parameters in the way described
no nevermind that you did that
RoomOptions is not in the Photon.Pun namespace, it's in Photon.Realtime
Im using netcode and steamworks, this code doesent work anymore?
NetworkManager.Singleton.GetComponent<SteamP2PTransport>().ConnectToSteamID = hostSteamID.m_SteamID;
Does anyone know what type im looking for instead of <SteamP2PTransport>
In NetworkManager settings i'm using the protocol called SteamNetworkingTransport, how do i call for that? 😄
Yes, basically what I’ve been told is that Mirror is just Unity’s deprecated networking solution with a bunch of band aids on it. Fishnet offers everything that Mirror has except it’s completely free and has way more features. Plus small testing from me has shown that it is able to ping quicker than Mirror to various locations
I am making a somewhat FPS game but I refuse to work with photon for fusion or quantum. Although I understand I guys have beef with FN, I have no beef with him. If his project is better than Mirror I’m gonna go with it
^ Wont work with Photon because of their pricing/business model
seems pretty vague advice but there is no reason to discount fishnet... i've used stuff by first-gear and its always been well made. No idea why unity has (had) such a hard time coming up with a complete solution on their own.
Maybe we're all just less component than the developer of fishnet 🙂
Unity needs an integrated networking solution like Unreal Engine
unreal is a much more focused product than unity. there is no point in comparing the purpose built features of unreal that make it easy to build FPS type games with a general purpose framework/engine like unity
I think it’s fair to say that Unity needs an integrated networking solution
Networking is an integral part of game development
it would actually be interesting to have a peek into all the considerations you are making when coming up with features/implementations/architecture... especially why certain things aren't done this way or that. That would maybe lift some of the misinformation/-conceptions surrounding networking.
We had a bunch of public discussion threads in our RFC repo a while ago https://github.com/Unity-Technologies/com.unity.multiplayer.rfcs
Hi, I'm totally new to Unity Netcode and I wrote these few lines, is there any "OnClientConnected" event? I can't find any info
Yes it's called OnClientConnectedCallback
You can use it like this:
public void OnConnected(ulong clientId){
}
public void Start(){
NetworkManager.Singleton.OnClientConnectedCallback += OnConnected;
}
oh thank you
I have only another question, how can I set the IP that clients have to connect to? Is this the way?
If you GetComponent that, you can change that address
thank you
Yes I find it odd to totally discount any Photon product, but do listen to the guy who sends spambots to Mirror and here
Uhm... am I doing something wrong? I can't find the component type
If you try VS's quick fix, it should give you a namespace to import I think
oh it worked, thanks
While it’s true that Mirror has roots in the deprecated networking solution architecture, the bunch of bandaids statement is invalid. Mirror started out as HLAPI CE, and aimed to fix the bugs in Deprecated UNet, but then the developer wanted to go MMO scale. There are some things that have been improved dramatically. Comparing deprecated UNet now with Mirror is like night and day - Mirror does things that UNet could only dream of. 🙂
You will get mirror naysayers that will bash Mirror out of spite.
Besides, Mirror has been used in a large variety of games, be it Desktop, Console or VR. Naysayers said oh Mirror never will do VR networking… well, I bet they ate their own words when Mirror powered VR games started arriving.
If you are going to use FN, by all means go for it. Do that, make your game, hit it big and retire on a tropical island somewhere. Just keep in mind that support venues are pretty much locked to FGG’s outlets and expect things where the developer will just go “sorry, can’t help” and change topic.
Also check out Mirage, it’s what I’m using for my own shooter.
Networking is something that has many tools for the job
Yeah can't beat that mirror community. Great folks over on their server.
The fishnet dude not only creates fake accounts that talk to each other and spam other discords, he also disingenuously has garbage like this:
Which is just a lie, and used to be worse until it was edited.
I'd have a spine and not support someone so transparently trash, but hey 🤷
Hello-
I am trying to understand to protect my database. the issue is that my "Student entity" has a read/write policy/role to the "Students" table.
all the students have the same policy attached to their identity.
But Student A might make a request to change the value of Student b by using the access token belonging Student A
how can I prevent this issue?
Then I have to make a lot of claims for each of the users individually.
But it is a huge work to do
Which is the latest multiplayer system in unity?
Netcode
thx
So I was going to have my multiplayer game make the players the server so I don’t have to pay for a external server. But then I realized if I want it global it still needs one location to now who to talk to. Is there a simple way of doing this?
can someone help me make a udp server which sends one string of data contating all the information nescesary between users
hello, I am trying to use wantstoquit event from unity to show a message on screen to the player if he is in combat, the message appears but player is disconnected from bolt, any idea how to keep player connected, considering wantstoquit is exactly to cancel quitting the game? (using photon bolt)
That sounds like a bad idea, why not use any existing networking solution? You dont need to use their high level stuff they can also let you just send raw data.
If you insist on doing it yourself then just use UdpClient https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.udpclient?view=net-6.0
Be sure to join the Photon discord, better chance of getting PUN questions answered in the PUN channel there than here.
Copy that
Thanks for the info man
Well it seems there is no discord server for photon
Let me get the link, if it allows me to post it here
https://doc.photonengine.com/en-us/fusion/current/getting-started/get-help
Not going to risk pasting the discord invite here, I think that is disallowed. But the link is on the photon page there. @rough timber
Your discord link is really hard to find btw. I suggest putting it in the web page footer or something like that if you want people to easily find it.
Using Unity Netcode I connected a client to my server and the connection works good (client has ID 1)... but when I see the "NetworkObject" script on the client, here is what I see
it says that the owner is the client with id 0 and that i'm not the owner of the object
Any ideas?
Yeah, will ping the guys about that thanks @verbal lodge
Is this a player object or how did you spawn it?
uhm I spawn the object like if it was a single-player game, so I just put the prefab in the scene... Maybe this is the problem?
Scene objects are owned by the server which has id 0
oh ok understood, thank you
btw where can I find a documentation to know things like this?
Have you seen our docs site? https://docs-multiplayer.unity3d.com/docs/getting-started/about
yeah but is it still a work in progress?
It's constantly being improved on.
oh ok, so I'll check it often, thanks
which is the best way to make a movement system in Unity Netcode? Should I send an RPC request in the update to send the server the new translated position?
i mean, is it good for the server to get a request every update?
Something like this
Does Mirage have a discord I can join?
Uh yeah, it does 🙂
https://miragenet.github.io/Mirage/ it’s on there
I won’t directly link the discord as it may violate this discord rules doing so and moderators might get annoyed
hey uhh.. one of you boys I think cooper was offering invite without the phone verification would you mind getting me on with that too? Phone is MIA would love to get back in the server 🙂
@mortal horizon
Yes
Done
thanks!
Is there any good github example with Steamworks.net and Unity? I want to test lobbys and syncing gameobjects
Facepunch is a friendly one on git, not sure about examples its fairly popular though shouldn't be hard to find..
Yeah, but i have managed to get the new Netcode work with Steamworks.net, i only need some details regarding spawning, movement syncs etc, Only steamwork example i found is not working 100%, Where do you find you examples?
I dont get it, when i starthost i get the player prefab automatically, but when StartClient is triggered, no player prefab is created 🤔
Ah haven't used the new netcode for gameobjects myself.
Make sure your client is connecting to the lobby etc sounds like hes not getting command to spawn character or something..
What do you mean by StartClient is triggered?
Also I have a very simple sample project using the steam transport here which spawns players correctly: https://github.com/LukeStampfli/Netcode-Steamworks-Sample
Oh thank you so much! Is this updated to work with Netcode?
It's using netcode 1.0.0-pre4 I think. I created it to test whether the steam transport works.
it's laggy, you want to do client side prediction to interpolate between the network gaps
so i need something like a Vector3.Lerp between the position 1 and position 2?
No, you don't know what position 2 will be. You need to tell the server, "I'm moving to the left now" and until the server tells other clients otherwise, it's moving to the left. Basically, but that's a sparse explanation.
I figured out this
is anyone available to voice chat with me about networking requirements for releasing a server protocol setup
Using Unity Netcode - should a network object parented to a network object work seamlessly?
Also I am consistently getting an error message saying that I am leaking memory due to a native list. This only started happening once I started using NetworkList. Is there something I need to do to properly dispose of these objects?