#archived-networking
1 messages · Page 101 of 1
You just gotta make sure you are sending the i mean
One might get confused with local data when dealing with this stuff
Well, thank you very much. I'll then do some more research to make sure I'm sending the data.😇
I think i might use photon but i will also probably use tom welands C# tutorial/ Sockets
I cant wait till fusion releases
hey, im using the free photon unity thing, and got it set up so that i can create and join rooms. I made it so that whenever you create a room/join one, a start button needs to be pressed to instantiate the player prefab. and it works, but the player sees the other player floating slightly above the spawn and syncing eachothers animations but not movement despite me adding a photon transform and animator view component to the player prefab
pls help
Has anyone had success with AWS Gamelift using their Realtime Servers? I've got a simple test setup and I'm able to connect to a GameSession but my Unity Client can't receive any messages from the server (server log shows the client can successfully send to the server). Client logs indicate that the UDP connection doesn't seem to be connecting, but no obvious reason why (I seem to be choosing a correctly open port in the range recommended in the AWS documentation). What's odd is it was working for a while before it stopped working, and I don't think I've changed anything. Just wondering if anyone else has experienced this.
Hello.
How can I get all the documents in a collection?
Here I had to use Type to Equal but I do not want to use equalization.
{
dishes = new List<EatableBaseClass>();
Query capitalQuery = db.Collection("restaurants").Document("RedRest").Collection("menu").WhereEqualTo("Type", "Kebap");
capitalQuery.GetSnapshotAsync().ContinueWithOnMainThread(task => {
QuerySnapshot capitalQuerySnapshot = task.Result;
foreach (DocumentSnapshot documentSnapshot in capitalQuerySnapshot.Documents) {
dishes.Add(documentSnapshot.ConvertTo<Dish>());
}
});
}```
I want to download all the documents belonging to "menu" collection by one by
you should prolly find the game lift forums, I think AWS has a discord or a slack.
Photon has a cloud hosting solution with it and offers some products that differ from Mirror/MLAPI. But PUN2 is free and Self Hosted Server is really cheap.
Yeah, good point thanks. Seems likely a problem in the C# SDK for realtime Servers and maybe how unity is interacting with the networking stack it's using so thought I'd ask here.
trying to understand networking for crossplatform input
how do i obtain players IP address in this instance?
seems to like this slightly more
Hello! what is the best online engine for begginers and a fps game like among us?
How to change server at FPS Sample?
Hi guys, I'm using mirror, but when the player spawns he flies away into the sky, I can't send the code here because it's too long, help me pleasee
Well that is unhelpful, try putting the code in a paste site and linking here
unity engine networking is deprecated
this isn't really enough information to decide what "engine" to use. I would say go with Unity and pick a networking library that works for you...do you need peer to peer? Photon Bolt. Automatic hosting? Photon or PlayFab.
@olive vessel Good idea, I'll do this
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.
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.
The problem is that that when the player spawns it flies up
can you try setting the rb velocity to 0 on start @cursive field
We can confirm this is not an issue with your moving script and maybe some weird spawning behavior.
ok, i'll try but i can confirm it because it was working before adding networking to it
@grave ice what do you mean with rigidbody velocity?
in the script?
Player controller line 11 you have a rigid body
okok
use this to figure out how to change the velocity or any other properties https://docs.unity3d.com/ScriptReference/Rigidbody.html
So use rb.velocity, for example @cursive field
yeah okok
Ok I've added this line to the start "rb.velocity = new Vector3(0, 0, 0);" but nothing changed
wait can i call you on Discord to show you a thing with screen sharing?
@grave ice
you can post resources here so others can help too
okay so its a problem with your movescript then
Ok
I'm not too familiar with 3D movement but I'd recommend looking up "unity 3D move scripts"
oh I did not know that lol
So it will surely be a networking problem
anyone do any dedicated server / multi client architecture setups here? I'm working on one that uses the SignalR libraries
can you elaborate
Sure, did you have a question or need help? I've made a few prototypes with hand rolled Websocket Servers.
I just want some advice on abstract implementation. I have a setup where clients will be running a "thin client" like Unity app--let's say for mobile right now. The mobile device then connects to a server using SignalR and uses a Hub to make remote calls on the server (requesting authoritative data). The server should log it and send back JSON data to the client. Right now I have a demo that does this, but it's such a big thing to look at (SignalR, WebSockets) that I'm afraid of making a mistake that will be a security issue. How should I implement secure sessions using SignalR?
Can someone tell me the difference between photon realtime, pun and bolt?
Which one is the best for like a competitive-type fps game?
also no peer-to-peer
Making sure the Websocket connection is a secure connecting (with TLS) is a good start. Not sure specifically how SignalR does it but I'm sure there are docs. You'll need your server to be using a domain name and to get an SSL cert for it (letsencrypt can get you a free one)
yeah right now I'm just using a self signed for localhost testing, I plan on doing that exact thing though. I'll just go for it with a TLS connection and see what happens
this plugin looks promising for a jump start on it https://assetstore.unity.com/packages/tools/network/best-http-2-155981
Has anyone used that plugin by chance?
I've noticed a lot of people saying MLAPI is in development and probably not the best networking solution for commercial use. When it is fully developed will it be the standard? I'm trying to choose a solution for hobby projects with the purpose of learning/building a portfolio and am curious what path to go down
That was a decision I faced early on. By it's design, MLAPI will never be a good solution for multiplayer when you want a dedicated, authoritative server that runs completely different code than what runs on the clients. MLAPI and other client hosted solutions run the same code on each client as on the server (so that a player becomes a host) and then focuses on permissions from there. What happens when a malicious player becomes a host breaks the entire system apart.
so now I'm into the weeds with using a web development framework for a video game because the engine doesn't provide an option that I want, but that's just me being picky I guess
There are other's who had the same sentiment in their blog post from last year https://blog.unity.com/technology/choosing-the-right-netcode-for-your-game but you notice that all the suggested solutions (excluding DOTS) are not dedicated server architectures.
Thats a great article thank you, mirror has the same downfalls? read your edit
Aren't most of them primarily dedicated server solutions?
PUN stands out as being primarily peer to peer over relay and actually one designed for host migration
By default, most people will be running the same build on a client as they would on the server. This is not really a viable commercial solution, unless you're making a game where that's ok, like minecraft. In my mind, I wouldn't want a client to even have a binary of server code on it. I need something that is more secure.
Luke Unity is a project lead on this--he's comin in with the best info
This is not true, you can run dedicated authoritative servers with MLAPI. You can run different server and client code with MLAPI. Same goes for Mirror.
don't you still have to run tons of checks everywhere to see if the the RPC is being called by a client or server?
Yea I think viewing them more as something similar to Minecraft or Source games, where yes, the clients often ship with the necessary stuff to be a host, but you don't necessarily run them in a configuration where the host is changing and you have the option to run them as dedicated servers.
MLAPI has a very clear distinction of server and client code. For instance a ServerRPC will always be run on the server.
You can still build dedicated servers by having the server and client code in the same project/scene. This is fairly commonly done if your server side code needs access to engine features such as physics.
If you are afraid of cheaters you can also strip server code from your client builds by using the #UNITY_SERVER compile define.
okay that clears it up for me I think
arg that just seems like a LOT of if statement defines
what I have done in the past is build a second project in Unity that is the server, that has completely separate code, and use a socket connection to communicate back and forth between client and server
that way the server has access to all Unity engine stuff and the code running on the client isn't the same as the server
but then I realized for my specific application that I don't need it on my server--but that's irrelevant haha
Yeah I wish we would better support that pattern with MLAPI. I think we can get there though. In theory you can already do that with MLAPI there is just a lot of undocumented things which can go wrong.
I found https://github.com/Unity-Technologies/DOTSSample as a good starter
Can't you technically revert to sending network messages and ignoring the features of the library?
Not exactly sure if there are a lot of benefits at that point though 😄
First party serialization support?
There are also other smaller features you could still use like ConectionApproval. But yeah at that point you can just use a low level transport library like the Unity Transport Package.
Hmm so is Unity Transport and Netcode/DOTS as a whole the future? Seems like what I should be working with Nevermind, it obviously is. Time to jump in the rabbit hole
MLAPI, UTP and DOTS Netcode will all be part of our multiplayer stack. Each of them fills a different role:
UTP: Either for simple games or advanced teams with netcode expertise, allows you to build your own high level solution.
MLAPI: The netcode solution we provide for the GameObject/MonoBehaviour space.
DOTS Netcode: The netcode solution we provide for DOTS ECS.
is UTP a pretty thin wrapper around basic TCP/UDP, just baked in to work well with Unity's update/execution cycle? Or put another way, what would be compelling reasons to use alternative networking libraries (e.g. https://github.com/RevenantX/LiteNetLib) over UTP?
Is anyone getting this error when they build their project?
ArgumentException: Value does not fall within the expected range.
at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue) [0x00000] in <00000000000000000000000000000000>:0
i do the same
any PUN2 experts please dm me. I need help
@somber sable you really should just ask it here
This is likely a buggy Editor version. Would recommend upgrading.
The Photon team is on the Photon Engine discord server. Not sure if I can post an invite here...
Or just ask.
@high night You wrote your own netcode for your game right? About how often are your client predictions wrong from the server?
I'm using the default character controller component from unity and every few seconds my client is off from the server by about 0.001
not a lot ik, but it's on the same computer and I was under the impression that it was supposed to be deterministic on the same machine
just curious as to what values you're getting
@teal obsidian I don't check for prediction errors like that, i just put the client 1 secont ahead of the server as if client had 1 second of latency, so there would be 1 second of predictions. And i try to make sure it stays stable like that.
I just send states back from server for each tick
And client just rollbacks everytime assuming as if whole prediction was off (i didn't care about average case, i think worst case is what matters here)
I don't think you'd be able to rollback unity's default character controller very nicely because i think it holds some states that we don't have access to
Maybe not, i just skimmed over it and decided i would go with a rigidbody controller instead to not have those kinds of issues
@teal obsidian The reason your character control rollback is not deterministic is most likely these unhandled internal states in the character controller.
I'm making a multiplayer game rn and I'm at the part where I'm handling movement. Is it ok for performance to send a packet to each player for every entity movement or do I need to put multiple movements into one packet?
@viral minnow I believe if you use syncvars or streams, they should be optimized nicely
umm. I have no idea what syncvars are. Also I'm using java for my server
They should have a send rate you specify, i believe they are packed into one packet at each step
client is unity tho
how big should the packages be?
I had asked this question before somewhere i think
I'd remember it should be good if your bandwidth is below 100kbps
that makes 10 kp per packet if you send at 10 hz
for 1 client
I think you should be below that anyways
10hz send rate adds to the latency indirectly though
one movement packet is like 8 bytes so it's probably ok
If you wanna build some crispy action game, you'd need faster send rate
I'd be okay with 10 i think
I had made a game with 9hz send rate
Which was the default value i think
Wasn't so bad, well it was bad because of my netcode
yeah
why 100kbsps btw?
Thats just the value that i head in my head, i dunno where it comes from. I remember talking about that in some discord channel
this here @teal obsidian same as we suggested you...
these are spot on
However, packets of 576 bytes or less are guaranteed to traverse the IP network without getting fragmented (which means you will have fewer dropped packets).
@viral minnow
I read something like this
So smaller is better
np
the IPv6-specified MTU (1280 bytes) should be universally supported
I feel like there's a lot of buzzwords around choosing frameworks. I think DOTS will be the eventual "holy grail" path people will want to take for their games if they want dedicated multiplayer server and multiple clients connecting to it--if Unity pursues that as an option. If you do want hosting ability built into your game, then you should go with MLAPI. Otherwise, make your own since it looks like a viable dedicated server solution is not coming anytime soon, and putting in potentially hundreds of #UNITY_SERVER statements seems pretty painful.
hey guys I need major help with syncing a variable in PUN2. I have a photon view on the object with the script attached. Im trying to reference the child of the gameobject to sync up but it wont work https://pastebin.com/NAeidZ8L
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.
Is that a tedious thing to do
If you prefer hunting that low level bug...
Within the same LTS version, you can upgrade to newer builds.
Ok, thanks
Right, I am reconcilating every single tick no matter what (forgot to include that information in the original posts), I just wanted to see if there was a certain amount of error that was "normal" but it does in-fact look like it might be a problem with character controller's internal states
anxiety starts to build up when I see miscalculations like this and it makes me feel like I'm doing something wrong. That's my reason for asking people about their experiences with this.
It sounds reasonable to me. If anything it's good, makes sure your reconciliation is working :)
It's totally normal for the predicted vs server state to differ slightly, there's tons of possible reasons. If it's not disruptive to your game play you're fine. It's better to focus on handling when things go wrong properly then trying to prevent them.
{
foreach (Transform o in this.GetComponentsInChildren<Transform>(true))
{
o.gameObject.layer = LayerMask.NameToLayer("Hands");
}
}```
using Mirror
does anyone know why this if statement is never true?
input is a network behaviour that lies on the parent of the player prefab
this code is being called on a child gameobject
if its not your local player then the ststement is false
yes i get that
but it is indeed my local player
in fact on the input class, i use isLocalPlayer to check for input and it works fine
I'm working through the Getting Started with MLAPI tutorial and was thinking about how you all test out your projects. Do you build everytime and setup a host and multiple clients or is there a way to do it within the editor?
i figured out my issue btw. it actually had to do with the fact that i was calling my code in Awake. i suppose server side stuff is also initialized in awake, so that was causing a conflict with isLocalPlayer not being assigned yet
changing it to Start worked
I'm looking for a way to save player progress, and sync two clients together.
For the player progress, it sounds like I'd need to setup a database, with a login, register and password reset system.
Once I have that up and running, I'd use the logged in player_id to match two clients together?
In order to connect and sync the clients to one another I'd want to use mlapi?.
I'm very new to Unity in general, and was wondering if anyone could recommend any resources / tutorials for me to look through?
I understand this is probably way out of my depth for my first ever project, but I need to learn somehow. xD
@verbal gorge Networking solutions give you ways to call RPCs on remote client or server with remote parameters
That's how the communication works
You can handle figure out your own serialization and send byte arrays in those rpcs
I haven't used mlapi yet, it looks like it has some nice stuff to make the serialization easier
I'd look for a bare minimum tutorial to get started with, at least that's what i back then
I had followed a tutorial with player capsules shooting projectiles and synced health
If you want to have players host on their own p2p style, you might be better off with photon, or figure out mlapi to work with steam or some other relay system, or use steamworks transport in mirror.
https://www.youtube.com/watch?v=4Mf81GdEDU8&t=562s
This series has been helping me a lot, it doesnt cover saving player data but it does go through connection approval, RPCs, and syncing network variables @verbal gorge
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/
----------------...
MLAPI has no prediction/rollback feature currently.
I see, thanks
That doc page is just a glossary which explains some common netcode terms.
I see yeah, i didn't pay attention to the title, my bad.
I have a deterministic lockstep model working, and I need to send a simulation state for when a player joins late.....
I can either send the entire map state over the network, or I can send a complete input history and have the client simulate back up-to-speed
Does it not make sense to use lockstep and sometimes send the sim state? It feels illegal 🤣
late joins you should send a compressed snapshot
interestingly there are some older games that do the latter actually. Warcraft 3's china client (netease) has a rejoin feature that uses fast forwarded inputs. Though ofc this is because the game can not serialize its state, and isnt the most practical 🙂
that's just technical dept @floral turtle
oh, lets not spend time creating a proper serialization, lets just send the input history...
That works for joins at and close to the start.,.. but with a long running game, it's not a good approach
It's considered a weakness of the model (if snapshots are not implemented)
I can tell you from experience with several several customers...
Since we introduced automatic snapshots in quantum, not questions are asked...:)
yes, I cant imagine any modern deterministic games would do that. Since even if you are forward only I assume most modern determ games build out a snapshot system for checksums
but I find it a nice property of determinism that you can do things like rejoin with inputs. Shows how elegant the system is
even if you wouldnt use it in a practical sense
Snapshots meaning the server sends the serialized game state ?
for checksums? Do you mean that whenever checksums dont match, a snapshot is sent ?
yes
that's an option... you can even run the game also on a server, and enforce a snapshot on the client that desynced...
But that's more like an overkill protection against accidental determinism bugs left by the dev
We have ONE customer doing that... It's always possible
I imagine its more relevant to realtime games, turnbased lockstep dont need to worry about checksums always matching
makes sense
you are correct, not really that much necessary... But it's a good thing to have IF it can be done turnkey
And it's useful for development
We have that in quantum, together with a frame-state dump+diff tool...
So that's super useful during development to spot where you make a mistake
and good point, I should use input fast forwarding if the time it takes is minimal (not many turns behind)
ah very cool
I'm doing basically what TrueSync did, which is FixedMath (C# fixed math) on top of an existing physics engine
Thank you guys for your advice @gleaming prawn @floral turtle
I was the original developer of TrueSync btw
I am trying to make a multiplayer game with Photon Pun
When i instantiate a attack prefab. the player who didnt create it oul get ths error
Ev Destroy Failed.Could not find PhotonView with instantiation 1005.
I am using this to destroy the object
if (gameObject.GetComponent<PhotonView>().IsMine)
{
PhotonNetwork.Destroy(gameObject);
}
very cool!
I have a question for you
is it dumb to send anything other than longs for FixedMath?
fixed math's raw values are longs so those are safe to send
According to the dev, conversions may not be deterministic since its unspecified https://github.com/asik/FixedMath.Net/issues/9
this is not a problem
If you convert form float directly from the machine that is sending that as input
So not sure what your question is... If you know what you are doing, this would not be a problem
If you convert from float to FP inside the SIMULATION, then you are screwed
You can't do that...
does anybody have even a single clue how to use the eos sdk
Hey, can anyone help me with a question? (I am still pretty new to networking) I am creating a 2 players multiplayer game, one hosts and the other joins, I am using Mirror to do it. But I can't figure out how to make my friend connect in remote, because all I had done at this point was using localhost to connect to myself using Mirror built-in network GUI. Do I need to set up a dedicated server for remote connections or is there a simpler method? (For now I just want to test the game with my friend, so even if there is a simple way even if it's not practical in a real published game, that will also do)
If you are hosting as a client, he uses your public IPv4 and you need to port forward
Not specific to Unity, but wondering if there's a simpler way to get all players to handle an event at the same "wall time" in a P2P, client authoritative setup. My current thought:
- Elect a 'leader'
- All non-leaders synchronize clocks with the 'leader' (Something NTP like, send current time, get a response with the sent time and the leader time at receive time, factor in round trip/2 to your offset)
- Leader sends a 'handle this event at x my time'
- Non-leaders can translate x leader time into y local time, and trigger the event then
yeah so right now each machine converts a few floats to FPs and uses it in the simulation....only longs are sent over the network
I imagine conversions are only an issue if conversions are indeed not deterministic, which the developer stated he is unable to find out.
But I'm going to to avoid floats and just use longs to be careful
You can only convert to send as input. In the sim, floats are prohibited
And you do not need to send fp or long as imput, these are too big
Send packed bits
Use ticks (fixed timestep) instead of clock timestamps as the basis of your simulation timeline.
Like keep the same idea, but use tick values instead of clock timestamps? Synchronize tick numbers, send the tick number to handle the event on?
I was imagining using Time.time, are you suggesting tick count instead because it's more reliably consistently incremented across clients?
to be clear: the sim is 100 percent FPs, just like TrueSync
I convert a few floats to FPs to construct physics objects in the sim
if converting floats to send input is deterministic, then I can assume converting all floats are also deterministic
so my approach should be good right?
is it possible to get MLAPI.Relay up and running on a local machine and would I just have to open the relay port on my router?
I need a simple library to make peer to peer multiplayer game. Any recommendations?
Needs to be fast and easy to implement.
The game will be simple, i just need to send like player position, and like 5 integers over network.
Everything i found its server based network.
@livid junco by p2p do you mean where players themselves act as a server ("host" or "listen server") or like an actual p2p network?
Converting is not deterministic. It works because you do from a single machine, and then all sims use the same value.
@gleaming prawn thats not entirely true with FixedMath (the library) but I understand your point
thank you btw
I’m just telling you the principles. I wrote two deterministic libraries which were/are used by dozens of released games… so I have a bit of experience on the topic.
yeah I appreciate the explanation, and that makes sense now.
should clients be trusted to convert and construct their simulations the same? instead should i have a snapshot determine the state of all clients to start ?
for example with TrueSync/Quantum, do you have each client convert and build the world separately but identically? Or you start off with a single snapshot
If they build from floats it would differ
You either pre-bake the worlds saving in fp in the build, or you build procedurally from fp, or as last resort you let one machine creates and pass the initial snapshot
How to get a count of available rooms in pun 2? And what is the differences between photon server 4 and 5?
Hey 🙂 i have a problem with my current game... the players in my online game should have the ability to place walls ingame and for some reason only the host can place walls properly (with properly rotation), but for some reason the player who joins the lobby, cant place walls with a rotation... here's my code about placing and rotating walls:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class WallPlacing : MonoBehaviourPunCallbacks
{
public GameObject wallPrefab;
bool isInstantiated = false;
PhotonView view;
void Start()
{ //get the photon view component
view = GetComponent<PhotonView>();
}
// Update is called once per frame
void Update()
{
if (view.IsMine)
{
if (Input.GetKeyDown(KeyCode.LeftControl))
{
view.RPC(nameof(PlaceWall), RpcTarget.All, Camera.main.ScreenToWorldPoint(Input.mousePosition));
//view.RPC(nameof(RotateWall), RpcTarget.All );
}
}
}
//place a wall at cursos pos
[PunRPC]
void PlaceWall(Vector3 position)
{
GameObject wall = PhotonNetwork.InstantiateRoomObject(wallPrefab.name, new Vector3(position.x, position.y, 0), Quaternion.identity);
var dir = Input.mousePosition - Camera.main.WorldToScreenPoint(wall.transform.position);
var angle = Mathf.Atan2(dir.x, dir.y) * Mathf.Rad2Deg;
wall.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
//wall = PhotonNetwork.InstantiateRoomObject(wallPrefab.name, new Vector3(position.x, position.y, 0), Quaternion.identity);
//RotateWall(PhotonNetwork.InstantiateRoomObject(wallPrefab.name, new Vector3(position.x, position.y, 0), Quaternion.identity));
}
}
In the video you can see what i mean...
thank you for your help and your time 🙂
gotcha, I understand the concept of this
in my product, however, I have gotten deterministic results everytime while building from floats
Since FixedMath's conversions are deterministic except in cases of overflow, and the developer still hasn't confirmed its not-deterministic.
For my case, I can keep my setup and add an initial checksum comparison to send sim if needed. A better setup will be avoiding using floats and will use longs instead...thank you so much for the advice! Really appreciate it @gleaming prawn
FixedMath has no deterministic float conversion. It's just a regular 31.32 fixed point implementation. You might get deterministic results on the same machine but you won't get it across different hardware.
According to its developer, conversions are completely deterministic EXCEPT for an overflow case when casting...but the behavior is unspecified, meaning it may be deterministic still...
In fact, the developer says the behavior can be made deterministic if you enforce a min-max for casts, or by throwing an OverflowException (using the "checked" keyword)
a single division or multiplication should yield the same result across any compliant implementation of the floating point standard.
According to my knowledge this is not true. And can easily be debunked with a Unity build on PC + Android.
The IEEE floating point standard does define how floats are represented in memory. Different CPU manufactures still use different methods to perform operations on those floats.
what about this post (it was in the thread I linked) https://stackoverflow.com/questions/39364096/does-single-floating-point-operation-calculated-at-higher-precision-and-immediat
There is a paper that proves that that question is correct (read top answer)
Also the dev addresses your concern in this post https://github.com/asik/FixedMath.Net/issues/23
This paper talks about truncation of doubles to float. It does not talk about floating point determinism across platforms.
thanks, yeah you are right about that
The comment in issue 23 is correct.
The problem is how you obtain the float in the first place.
float foo = 5f will not give you a cross platform deterministic value.
Doesn't the developer in issue 23 state these conversions are fully deterministic (minus the one issue he points out) ?
He states that his way of converting an existing float to long (by multiplying) is deterministic.
true, so even if the conversion preserves the value, the float is not deterministic
thus stating conversions from float->fp are deterministic?
Well actually after reading issue 23 again. The developer is just wrong.
can you elaborate
the float is multiplied by an integer constant (this is floating point multiplication)
This is not determinstic
He makes assumptions about how the CPU does floating point multiplication. He might be right, he might be wrong. Depends on the hardware.
His comment though "The multiplication must be deterministic because the constant is a power of two (so it amounts to incrementing the exponent on the result)."
thank you so much for the help btw @verbal lodge
All I can recommend is really to test on all the hardware you plan to release. Don't assume because it is deterministic on one machine that it will also be on others.
gotcha man, I understand. After reading his comments, I was comfortable continuing to finish my prototype. I have tested on many different devices and have not experienced an issue yet.
That being said, I'll still include an initial chcksum comparison and send a snapshot if needed
again thank you
Please?
can anyone help me with Containerised servers through Docker? I get an error saying that the image doesn't exist, but I dont know where to make it
Please ping btw :)
Hey guys!
Has anyone encountered the exception "ArgumentOutOfRangeException: 'capacity' must be greater than zero." while using NetworkList with a custom serialized object in MLAPI?
It happens as the client attempts to join a hosted lobby.
whats the best networking solution for a small game, one thats only for my friends? i was looking into mirror and photon and i also heard about the new mlapi, which should i use?
Photon's nice because you can avoid port forwarding and all that jazz
Plus if it's only small and for your friends, I doubt you'd go over the 20CCU
It's a cool thing, but like Mirror requires hosting or P2P
@weak plinth Definitely PUN. Easiest API I've seen and the server is already running
hosting meaning like a server?
Yeah
ah
Whereas as Danny says, PUN does the heavy lifting
I wouldn't bother unless you are aiming for higher quality networking, like solid lag compensation and hit reg
Yes
ok ty
In fact I'm not sure what other Photon products work on WebGL 🤔
Well apart from realtime, which is a base for all(?) Photon gameplay stuff
Is it a bad idea to use animation events in a multiplayer game? specifically for an MMORPG? Im using a spherecast at the moment during attack animations
It was fine until I turned on animation culling and pushed to prod 😄
For a first time making a network game would you suggest MLAPI or PUN?
Fusion
Just released as a successor to Pun and Bolt (which will continue to be supported, but won't receive new features, etc)
Fusion is out ? Nice !
When I do PhotonNetwork.LoadLevel(); A first time on the MasterClient it loads for everyone, but when I try to reload the game with LoadLevel on master Again just loads on the master client and nothing for the others
If you need more details ask idk where to even start lookin
PUN does not support reloading out of the box. You may need to load an empty scene in-between.
Thank you, sad that feature isn't there, I've seen you a lot on the forums everytime I look for photon answers btw, It's like meeting a celebrity
Naaa, it's not but thanks all the same 🙂
is the tiger named tobi ?
That's Hobbes from Calvin and Hobbes.
i have this test case where I'm pulling an image from a url and applying it to a raw image I have in scene. It works in the editor however when I build webgl and run in browser locally I am getting CORS error and I can't understand why as I've added every header I can think of. I've also added a golang script to run this with proper headers as well but I still can't figure what I am missing?
Is it worth it for a smaller game to have a dedicated server basically for the sole reason of stopping (some) cheating (editing xp + currency) and preventing/increasing the difficulty of piracy?
Hey, anyone!
Is there a way to toggle Cloud Diagnostic through script?
I want to query the players before allowing crash reports and such to be sent automatically.
But I don't find anything in the API or on the web
Does anyone know how to make a multiroom game in Unity, similar to games like Habbo Hotel with one server with many "rooms"
I thought of making a general server which create seperate Unity "server" instances but I guess this would cause problems with ports and the like
photon has this arch built in
You probably wouldn't wanna use Photon for a game like that anyway, apart from maybe Realtime? If you wanna use Unity for the server, you should be able split things to some extent, like using separate PhysicsScenes and setting up camera culling. With logic you obviously have to take care to split them in a way where data isn't shared between them uncontrollably
Spinning up Unity instances for each individual player is indeed probably not ideal
good point
you may as well just run the server on unity at that point too lol
Hi all,
I want to call an AWS lambda function from my client (that will obviously be distributed to players). Is it best practice to create an IAM role that only has access to call that lambda function, and embed those keys in my code? Or what is the best way to do this?
It seems like IAM permissions are mostly regarding access to other AWS services
I'm really not sure, but aren't Lambdas publicly facing rest endpoints? And those permissions determine access to other AWS services (and maybe access to that lambda too)?
This may be what you are looking for https://docs.aws.amazon.com/lambda/latest/dg/permissions-boundary.html
When you create an application in the AWS Lambda console, Lambda applies a permissions boundary to the application's IAM roles. The permissions boundary limits the scope of the execution role that the application's template creates for each of its functions, and any roles that you add to the template. The permissions boundary prevents users with...
Is UnityEngine.Networking UNet? I'm confuzzled
to my understanding is was UNET . However at the moment it is "nothing" but MLAPI has been bought and is in development. Though it has to be imported as package through a git repository atm.
Ah. I'm trying to conceptualize a custom networking solution.
Hello! I am using PUN and have a question. There is an object in the scene Sword. Player can pick up it and make a new parent WeaponContainer so sword position and rigidbody is no longer needed to be sync as it is attached to a player. I change ownership of the sword but i need other player to know that there is a new parent object for this sword (a player's weaponcontainer). how can i implement it? with rpc i guess..
Hello! 🙂
I am investigating an issue with TLS on https requests to a webapp that is hosted on Netlify. The requests were working fine until last week, now I am getting SSL connection errors with requests to any website that is hosted on Netlify.app (I tested our application and multiple open-source ones).
My first guess is that Netlify changed their certificates and as Unity relies on the operating system to validate the certificate issuers, those new certificates would not be validated correctly until the OS was updated. I implemented a custom certificate validation, but it wasn't even being called. Then I ported my UnityWebRequest calls to HttpClient to see if I could get better exception/logs and got this:
TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_NOT_DONE
Looks like it is failing even before the certificate validation is done. All the pages that I tested have valid certificates and work fine on the browser.
It is quite easy to reproduce. With an empty project, I wrote a simple get request to https://hugo-theme-even.netlify.app/index.xml (first result for Netlify.app on GitHub) and the same error happened
Do you have any idea?
I mean a player for each room as in a server only instance of Unity, I would control these in a seperate "hub" or main server program
I assumed you were referring to the challenge of hosting server authoritative instances that may just have few players on each of them
How would one go about syncing bone movement over a network?
spineBone.transform.eulerAngles = playerMovement.playerCamera.transform.eulerAngles + new Vector3(0, spineOffset.y, -spineOffset.z); only works on the client, the rotation doesn't appear on anyone else's screen. it's inside of the if (hasAuthority) then statement
in other words yes
hey, does someone know if Physics.Raycast is deterministic? - given the case: i move my sphere colliders that shall be hitted by the Raycast, with deterministic code.
public class ServerList : MonoBehaviourPunCallbacks
{
public static List<RoomInfo> Rooms = null;
public override void OnRoomListUpdate(List<RoomInfo> roomList)
{
Debug.Log("sqddzqz");
Rooms = roomList;
}
}
Why does this never get called even though I connect and create a room
or is there a better solution to get all the rooms available
I'm using Ruffles from TwoTenPVP for rUDP so I can use a headless DGS (in fact, the DGS is completely non-Unity).
Is this approach on the client going to be performant? Singleton NetworkManager game object:
private void Update()
{
if (!Connected && !ConnectionInProgress)
{
StartConnection(); //calls RuffleSocket.NetworkManager.Connect()
}
else if (!Connected && ConnectionInProgress)
{
PollConnectionAttempt(); // polls the RuffleSocket for Ruffles.Core.NetworkEventType.Connect and marks the connection attempt as successful
}
else
{
PollServer(); // does mostly everything else by calling RuffleSocket.NetworkManager.Poll() and routing or invoking the messages accordingly
}
}
(I was struggling to get an async/await approach to work)
physics in unity is not deterministic by default
Since one has to use OnRoomListUpdate to get a list of the rooms, does that mean that if player A creates a room while player B's app isnt running then Player B wont be able to get a list unless a room is modified
how to disable that
Hey wanted to ask if anyone knew of a tutorial or guide/docos/information for how to set up a matchmaker (utilising unity and mirror)? The server hosting is strait forward and loads of tutorials on that, but I couldn't find anything on the matchmaker or game controller side. Don' t want to use steam because I want it to be playable on android as well.
there are a few solutions for this...maybe Photon? PlayFab?
mirror has this "node listserver" which can be a starting point for matchmaking. Also think https://www.youtube.com/playlist?list=PLDI3FQoanpm1X-HQI-SVkPqJEgcRwtu7M does a kind of matchmaking
I assumed Photon basically == mirror? is this not the case?
Thank you! That was what I was after! If you can also recommend any cheep third party solutions that would also be great.
Photon is a company, the provides several netcode solutions for unity (Fusion, Quantum, PUN, Bolt, etc).
Mirror is an open source netcode SDK, based on the old UNet API/Approach
They have zero relation to each other
ok cool thanks.
Does anyone knows the best approach on getting players standing on a moving platforms working with client side prediction?
I currently have to following options:
-Disable the client prediction on a moving platform and let the server take over the movement calculations.
-Predict the moving platforms on clients as well and let the client predict their movement on the platform.
Any thoughts/advice/starting google search queries/etc for structuring my network messages? Ideally they're binary or somewhat obfuscated, compact, secure (ie - not BinarySerialized), and extensible (so I can add features/messaging to the data structure over time).
(I would love to not pack/unpack my own messages)
There is no clean way to handle players on moving platforms when you're juggling two timeframes.
Think about the case with three objects: you (the local player), the platform, and a remote player standing on it.
Disabling clients' local input prediction isn't generally gonna fly, so realistically you have three options:
A) Predict yourself. Interpolate the platform and the remote player.
B) Predict yourself and the platform. Interpolate the remote player.
C) Predict all three objects.
Without doing weird hacky shit, A and B have problems at low server send rates.
If you do A, you'll mistime jumping on/off the platform.
If you do B, remote players will lag behind the platform, and sometimes just be floating in air.
In either case, lag compensation will break completely once you're standing on the platform. Fixing that would involve re-parenting everyone to the platform while they're "on" it.
C is the only clean solution, where you predict everything. You'd have to send the remote player's inputs along with the state data tho or you'll badly mispredict their movement.
This problem generally applies to any kind of shared physics object. It's why Apex doesn't even have elevators or moving platforms, just ropes and ziplines.
Rocket League does C, but that'd be too expensive for larger games.
Has anyone used MessagePack for Unity and got the code generation working? https://github.com/neuecc/MessagePack-CSharp#aot
Nevermind.. digging through the issues in his github repo, I found a workaround that worked - force the dotnet version to 3.1.x. I also fixed a bug - the class you want to serialize has to be public (obviously).
[MessagePackObject]
public class ISGMessage // won't work without the public keyword.
{
[Key(0)]
public string MessageName { get; set; }
[Key(1)]
public string MessageContents { get; set; }
}
Hello. I am using Firebase and want to write a linq expression to retrieve data from the noSql server. This code is an example for Entity framework
Do we have kinda solution for it?
I mean when I call this "GetAll" function from outside of this class, I will put some expressions and this expression will be my query.
Or I should just pass a firebase query as paramater?
Thank you in advence.
@dense hedge thanks a lot for the in depth explaination!
I will test out the 3 solutions you have provided, and hopefully can get away with option A or B because predicting remote clients is going to be a bit expensive for my type of game.
should i use MLAPI or Mirror for a multiplayer fps
and can both of them integrate with steam
I would chose mirror, which also supports a steam networking transport layer
hello, I am having issues with MLAPI that I can't quite get over with. My client calls a ServerRPC which seems to work, but then in that ServerRPC I attempt to spawn a projectile (because I assume I am in the server), but it says Only server can spawn NetworkObjects on the log... Any help?
Does this log appear on the server or the client?
Is your RPC on a NetworkBehaviour? Is that NetworkBehaviour on a GameObject with a NetworkObject component on it?
I thought it was, but it wasn't after all!
I wish they threw a log when you try to call an RPC and this scenario happens... even a warning one
Thank you, I'll try now
{
List<Restaurant> restaurants = new List<Restaurant>();
Query allCitiesQuery = FirebaseFirestore.DefaultInstance.Collection("restaurants");
allCitiesQuery.GetSnapshotAsync().ContinueWithOnMainThread(task => {
QuerySnapshot allRestaurantsQuerySnapshoot = task.Result;
foreach (DocumentSnapshot documentSnapshot in allRestaurantsQuerySnapshoot.Documents) {
if (documentSnapshot.Exists) {
Restaurant doc = documentSnapshot.ConvertTo<Restaurant>();
restaurants.Add(doc);
}
}
});
return restaurants;
}``` Hello. I am almost going crazy. this fucking function does not return this "restaurant" list
I got "0"
Debug.Log(restaurants.Count) = 0 If I call this function from outside of this foreach, I got "0"
do you have any idea?
Google Protocol Buffers are really great for this
I'm already using MessagePack over protobuf. I have some concerns, though, about using a binary serialization framework due to the security issues.. I'm not sure how I'm going to overcome that or if I'm going to "best effort it" until some point in the future where someone blows up my server and I have to switch over to JSON/XML 🙂
Sorry - I didn't mean to say "i'm already using X" in a negative way - just meant more that I reviewed protobuf but I think I like MP better (since it can support nullable types)
I'm not exactly sure how I want to structure my serialized class though.. maybe something like
public class ISGMessage
{
public MessageType ISGMessageType;
public string? MessageString;
public int? MessageInt;
... etc ...
public enum MessageType
{
ClientMovePlayer,
ClientStartMission,
ServerSendPlayerState,
ServerSendReward,
ServerSendMissionCompleteDetails,
}
}
I'm not sure about messagepack but I'm reasonably sure protobufs don't have the same deserialization security problems .nets basic deserialize does
hm .. i'll review that
my understanding is any binary de/serialization has security issues
I've also seen https://capnproto.org/
Although maybe the above structure is... stupid because it tries to generalize an ISGMessage.. maybe I should subclass messages based on the type (and things they need) and the parent just has the MessageType enum and no other details (or maybe something like timestamp/client id/etc) and have the subclassed messages have the details they need
I've done something similar using protobufs where you would have an ISGMessage with the common fields, the a "oneof" with the types of specific messages. Sorry can't help with message pack but used protos a ton in my day job
How would subclassing work with the deserialization, I guess deserialize it as the base class, then inspect the message type to determine the specific type to deserialize it as again.
I guess the equivalent would be yeah to have a type enum then a bunch of fields, one per specific message with the specific contents (ClientMovePlayer etc). So you always deserialize to a ISGMessage and then from the message type field you know which specific message field is populated.
how easy or hard would it be to integrate something like pun 2 in to an existing project that is still early in dev stages?
not caring how hard it could be really ill put the work in
Hm.. this is an interesting idea, I hadn't thought of that. TBH the deserialization part hadn't occurred to me.. the server doesn't know what the message type is when it's trying to deserialize it
like:
public class ISGMessage
{
public MessageType Type;
public byte[] Message;
public enum MessageType
{
ClientMovePlayer,
.. etc ..
}
}
public class ClientMovePlayerMessage
{
... stuff ...
}
... prep a message for sending ...
ClientMovePlayerMessage ClientMovePlayerMessage = new ClientMovePlayerMessage { ... };
ISGMessage ISGMessage = new ISGMessage { Type = MessageType.ClientMovePlayer, Message = MessagePackSerializer.Serialize(ClientMovePlayerMessage) };
byte[] networkMessage = MessagePackSerializer.Serialize(ISGMessage);
.. send networkMessage to server ...
.. on the server ..
byte[] incomingMessage = ServerEvent.Data;
ISGMessage ISGMessage = MessagePackSerializer.Deserialize<ISGMessage(incomingMessage);
.. if ISGMessage.Type == MessageType.ClientMovePlayer ..
ClientMovePlayerMessage ClientMovePlayerMessage = MessagePackSerializer.Deserialize<ClientMovePlayerMessage>(ISGMessage.Message);
this could work
(that was also a lot of code to write in discord directly lol)
I wouldn't even need to subclass it, although I suppose that would make handling it all easier - i'd always override MessageType in the subclass (so they could just set themselves, saving me a line or two of code everywhere - I would just instantiate a new ClientMovePlayerMessage with the relevant message info and the boilerplate gets executed in the constructor)
this is really good.
I think you could just do something like:
public class ISGMessage
{
public MessageType Type;
public enum MessageType
{
ClientMovePlayer,
.. etc ..
}
public ClientMovePlayerMessage movePlayerMessage;
public ClientStartPlayerMessage startPlayerMessage;
... etc ...
}
then you just deserialize it to ISGMessage and you know with field with the message is populated from the message type
but I suppose I'm not sure how message pack would pack unset fields, I'm assuming it would be very little, if any, overhead
but your approach would work too
if i did the above I'd use nullable fields, since messagepack can handle that easily (with no overhead)
ie,
public ClientMovePlayerMessage? movePlayerMessage;
yeah, makes sense
but I don't know if I like the idea of sending a monolithic ISGMessage object .. might make debugging hard
if there's a dedicated ClientMovePlayer class then i can probably do some validation inside of that class
like once it hits the server and is unpacked, validate it
you can do that either way, just one you have an opaque blob of bytes in the ISGMessage until you explicitly deserialize it into the type
and the other you just have one layer of serialization/deserialization
aye
i wonder if there's any performance implications for de/serializing something twice .. i'm assuming there is
i also don't know yet if de/serializing works from OS to OS - ie, if the client is on mac and the server is windows, if an "int" will always deserialize the same way.. i haven't got that far yet in my documentation/source diving
in any case thank you for being a sounding board in the design of this 🙂 i'll let you know how it pans out
i'm going to do it this way i think
np, good luck! cross-OS should be fine except for floating points which the platform themselves might handle slightly differently
I just realized that deserializing-to-json becomes a pain in the ass if i have to double-deserialize it
ISGMessage will be kind of a big class but I think that in practice, most members are going to be null anyway
i'm gonna test it out tho
the other option is if your transport mechanism has different channels where you can only send known messages of one type to
like you could do that approach but have a ClientMsg (messages created by the client) and a ServerMsg (created by the server), to break it up a bit
yeah.. i want to keep ISGMessage.cs in sync though, will be a maintenance nightmare if they're different .. both sides need to be aware of both messages anyway
unfortunately the nullable approach doesn't work - the nulls come across in the stream
[MessagePackObject]
public class ISGMessage
{
[Key(0)]
public MessageType Type { get; set; }
[Key(1)] public int? theInt1;
... etc ...
[Key(15)] public int? theInt15;
}
}
when it hits the server, the payload looks like this (converted to JSON):
ISG in JSON: [0,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]
that means that if i were to put nullable reference types in ISGMessage, as the game grew and there became more and more message types, a single message would get more and more bloated
too bad.. i'll try the "double-serialization" approach with the subclassed messages and see how it goes
yeah
the double deserialization works pretty well
very small transport
although i'm embarassed to say I'm going back through some really relatively beginner OOP stuff since in practice i rarely override/abstract things, but this is a pretty ideal case for it
I think this is right?
the idea being I create the message elsewhere in my application in one line, like this:
SendNetworkMessage(new ClientSendNameMessage("test").GetMessage()); //SendNetworkmessage takes an ISGMessage as a parameter
heh, nope, doesn't work, the ISGMessageTemplate tries to serialize "this" (being the parent, not the child) and fails since it's not marked as serializeable
I was hoping to avoid copying and pasting the GetMessage function in hundreds of classes but ... can't wrap my head around how not to do that
so it'll look more like this: https://hatebin.com/ziqizfknes
@dense hedge Regarding predicting on a moving object, if you just parent the player to the object on both the server and the client, wouldn't that allow for smooth predicted movement regardless?
the position for every tick that the server sends to the client, would probably have to be local/relative to the moving platform though, right?
I'm going to warn you right now that messagepack will create an absolute shit storm of garbage
and your garbage collector will cause lagspikes every few seconds depending on the size of the data
I know first hand from using that library
{
return GetAllSync().Result;
}
private async Task<List<Restaurant>> GetAllSync()
{
List<Restaurant> restaurants = new List<Restaurant>();
Query allRestaurantQuery = FirebaseFirestore.DefaultInstance.Collection("restaurants");
QuerySnapshot allRestaurantsSnapshot = await allRestaurantQuery.GetSnapshotAsync();
foreach (DocumentSnapshot snapshot in allRestaurantsSnapshot) {
Restaurant rest = snapshot.ConvertTo<Restaurant>();
restaurants.Add(rest);
}
return restaurants;
}```
Hello. Please help me out about this. I spend a lot of time and going crazy.
When I call the GetAll, Unity freezes.
How can I solve
Thank you in advenge
No, re-parenting doesn't fix anything.
If you don't predict the platform, then when you try to jump on it on your client you can mistime it and fall because the platform is in the past. It'll be in a different spot when the server does the same tick. The server would have to like lag compensate your movement.
If you do predict the platform, you have to handle its transition from interpolated to predicted (and back) to address the same issue, unless you want to predict every moving platform in the level at all times. Similarly, the remote player will look off if you don't do anything about.
Re-parenting is only part of fixing lag compensation, which breaks when you're on the moving platform too.
Imagine standing on an elevator that is rising quickly and shooting at another remote player also standing on it. By default, your movement isn't rewound but theirs is, so naive lag comp will make you miss.
Re-parenting just lets you get "rewound" with the platform, but knowing when to re-parent and un-parent you isn't trivial, unlike a vehicle.
Basically, avoid moving platforms if you can't afford to predict everything (client auth also can avoid this problem completely but yeah). But if you just gotta have them no matter what, predicting the platform (for as long as you're on it) and special-casing the remote player's avatar on the client so it collides properly is probably the least painful way to go. May also need to do some special-case stuff on the server too, idk.
No shit! OK, great to know. I'm not committed to it, although I did spend the better part of a day figuring it out and implementing it
@teal obsidian What serialization framework do you recommend? (I keep getting drawn towards protobuf)
I'm trying to do a bit of network programming and I'm feeling lost. I'm trying to sync deltaTime across all players every 2 second, but value is not synced. I'm using MIrror. Here's the code:
using UnityEngine;
using Mirror;
using System.Collections;
[RequireComponent(typeof(NetworkIdentity))]
public class DeltaTime : NetworkBehaviour
{
[SyncVar(hook = nameof(OnDeltaTimeChanged))]
private float _deltaTime;
internal void Start()
{
if (!isClient) return;
StartCoroutine(OnUpdate());
}
void Action()
{
float deltaTime = Time.deltaTime;
CmdSetDeltaTime(deltaTime);
}
IEnumerator OnUpdate()
{
while (true)
{
Action();
yield return new WaitForSeconds(2f);
}
}
[Command]
private void CmdSetDeltaTime(float deltaTime)
{
_deltaTime = deltaTime;
}
private void OnDeltaTimeChanged(float old, float newValue)
{
_deltaTime = newValue;
}
internal void OnGUI()
{
if (!isLocalPlayer) return;
var position = new Rect(0, 0, 2000, 50);
GUI.Label(position, $"My: {_deltaTime.ToString()}, Default: {Time.deltaTime}");
}
}
And here the result:
The _deltaTime isn't synced properly, it's different for each client. I can't understand why
Can someone give me a hint on why the _deltaTime isn't synced?
hey guys, anyone here?
just ask your question, not if someone is around (see the read-me channel)
You'll need to use pre-allocated byte arrays to serialize and deserialize into. BinaryWriter, BinaryReader, and memorystream. All built into C#
unity does some weird shit when serializing floats through binarywriter though, so you'll have to write your own function to do that
{
uint TmpValue = *(uint *)&value;
_buffer[0] = (byte) TmpValue;
_buffer[1] = (byte) (TmpValue >> 8);
_buffer[2] = (byte) (TmpValue >> 16);
_buffer[3] = (byte) (TmpValue >> 24);
OutStream.Write(_buffer, 0, 4);
}``` Which looks something like this
straight from one of microsoft's built-in functions
when using messagepack though, you might be able to serialize and deserialize into a struct, that might not allocate any garbage
I haven't tried it though
How do you think rust goes about doing it then? Because you can stand in the cargo area of a moving physx helicopter and not glitch around
you can also stand on the moving cargo ship and walk around and jump around on it, do combat on it, without glitching around
the clients also don't predict any of the vehicles, and just get the interpolation data from the server, so I'm not sure how you could be predicting the helicopter while standing inside of it
18+ Only: https://rustchance.com/r/1143
If you enjoy, leave drop a sub and if you want to submit clips for the videos, join my discord. https://discord.gg/zxtx56v
I hope you enjoyed the video! If you'd like to join the Rust Highlights Discord server based around highlights and Rust content (Also where you can submit your own clips), follow me o...
Hello.
I am trying to get all the documents that belong to a collection and returning them as a List<Custom>
but I get "0"
because of the async operations, that I supposed to use.
But my class inherits from an interface. So, I can not add the keyword "async" into signature.
I do not know what I am supposed to do
Can you please help me, I will buy you a coke? or a cup of tea 🙂
really 🙂
hey, does anyone know how to sync a ball so that it runs smooth for both clients (rn the nonmasterclient has buggy movement)
You are not... standing on a moving behicle is yet another special case
it affects lag comp a bit...
Is Rust server auth? If they're client-auth, they can skip dealing with it. Otherwise, they do one of the two ways I described.
if you are talking about PUN: try fusion
I believe it is client auth in certain parts (like BF)
what is fusion?
new netcode SDK by photon, successor to Pun+Bolt
can do full physics prediction on Unity
just by default?
do I have to change my current settings with pun only?
server authoritative with full client side prediction
it's a new SDK, not the same code as PUN
It*s all new
but there are similarities (there's a document pointing the concept mapping between them)
okay, I will look into it (in the hope that it will help me :D)
notice both PUN and Bolt are legacy SDKs, that will only receive bug fixes... Fusion is the new one that scales much much better and will be improved upon.
I moved them over to structs.. after your message this morning I read up on a lot of the performance issues and the other claims that the version 2 is much more performant in terms of GC/alloc than before. I'll keep my code loosely coupled though so I can migrate to some other framework (ie - protobuf or C# native de/serialization) in the future. For now I think I'm going to keep it though - mostly from a "knowledge investment" standpoint.. I spent a great deal of time learning this shit, I'm not going to throw it away yet. 🙂
using MessagePack;
namespace KaimiraGames.ISG
{
[MessagePackObject]
public struct ClientSendName
{
[Key(0)] public ISGMessage.MessageType Type { get => ISGMessage.MessageType.ClientSendName; }
[Key(1)] public string Name;
public ClientSendName(string Name)
{
this.Name = Name;
}
}
}```
the above is a pretty lightweight example, but it serializes nicely (compact) and my internal interface to create and send them is super light:
SendNetworkMessage(new ISGMessage(new ClientSendName("Bob")));
(ISGMessage is the message wrapper that only contains the type of message and the serialized message itself)
yep server auth
I'm not sure if they do lag compensation either since every bullet is a rigidbody
I could be massively wrong though
AFAIK lag comp does not have to treat raycasts and projectiles differently.
ah
so it shouldn't matter
There are only two ways to consider the moving platform problem.
You've got two timeframes and only one platform.
like it only becomes a problem when you, the local player, also want to stand on it
if you're just shooting from afar at someone standing on the platform, that's all good, they're both interpolated from your POV
right, but rust has a massive moving boat, that players can pvp on
I'd just like to know how they do that
maybe the local player and server position are always off by a little bit?
and reconciliation just corrects it?
if the boat itself moves in like a big circle than that's trivial to predict
what about player driven helis like the video I linked
its gotta just be parenting and letting reconciliation correct it
I dont see any other logical way
parenting just changes the coordinate system, why would that influence reconciliation?
yeah I'm not sure
If I want to have server authoritative movement would I move all the movement code to the server and have the client just send inputs over
little more complicated than that. Your client has to correct his position every tick
assuming you're predicting on clientside
I have a component from mirror that automatically syncs my rigid body but I can have it only accept calls from server so if I send inputs to move on the server I’d assume that this component will sync the rigid body of the client
yeah I think mirror might handle all that stuff for you. never used it before
some notion of re-parenting is "needed" for shooting stuff out of the helicopter, so that lag comp can spawn bullets in the correct position, but it doesn't help the timeframe paradox
oh I see now, if you re-parent, the idea is that your position on the helicopter is stable
yes
so when you jump, you still move with the heli, or the boat you're standing on
then you just reference the local coordinates
of the heli/boat
when dealing with reconciliation events
that makes sense to me
maybe @gleaming prawn can give his input when he's available
tldr for erick: we're discussing how you would handle standing on a moving platform with server authority and predictive clients
idk if you would even need to use local coordinates. maybe you could just use global coordinates. I have no idea
I think the question is "what does re-parenting not fix?" It won't fix the initial transition to board the helicopter/platform.
well the client can still move freely even when parented to something
so I'm not sure what you're asking
how do you when to (un)parent the player to the helicopter?
probably have an invisible collider in that cargo area
a box
detects when players are "in" the cargo area
maybe raycast the floor
sure, trigger volumes would be the go-to, I'm just trying to think about how this interaction plays out in your local view, the server's view, and say, the pilot's view.
yeah I have no clue. Hopefully erick can give us some further insight
I haven't played much with the helicopters in rust, but from what I have seen in-game, the transition is extremely smooth
either your movement onto the helicopter is lag-compensated somehow or you start predicting the helicopter from further away than just the cargo area
or it's client auth
definitely not client auth, rust is competitive
the helicopters are also not predicted in any way
Hello. I wonder which one is a good practice?
Instead of writing bunch of query, I will get whole firestore document and turn them into object and loop and find what I want.
Is it a good practice?
Or should I write queries for all the needs
Im trying to make a multiplayer game using Mirror, and I want players to have a primary and secondary slot for weapons that they can drop/pickup from the ground throughout my map. I say Mirror's official way of doing it on their guide, but it doesn't seem like a good idea to add to an enum and a switch every time I make a new weapon. Is there a way to just hold a networked weapon object without having to have specific behaviors based on what you're holding? Because their solution breaks the open/closed principle, right?
Fyre I thought you were writing an answer so I expected 🙂
I also don't know if rust is lag compensated either. If I'm truly familiar with how lag compensation works, it would add a huge load to the server
the projectiles are shot locally on the clientside, and then the server shoots and the client doesn't see his projectiles from the server
only the client ones he shot
What I'm trying to get at is that you see the rest of the world in the past by roughly your ping and some change. If you tried to jump into a moving helicopter, on the server that heli will probably be ahead by d = ~ping * helicopter speed
Lol my bad
which could be like a difference of 5m or something
your timing would be way off unless the server did something to compensate or you start predicting the heli much earlier
but the heli speed might be super slow and not matter idk
I'm still not sure if that would even be a problem in the first place, since you can still freely move onboard the helicopter right? What you're saying would be a problem if you became the helicopter pilot
yes
getting on the helicopter while it's at rest seems easy, sure
Sorry, time to go to bed here.
no problem
There are several ways to make this look correct
Look… you need to loose something in relation to lag comp (if they even use it)
But to look correct, a few ways. I just did a few experiments related to this yesterday, unfortunately it is a private video for some customers.
So I’m afraid I can’t help much
Look at the battlefield article
let's just say rust doesn't use lag comp, to make it simple, and because I truly don't think they do lag comp
@dense hedge do you have the link for it?
interesting, I'll have a look
so I think
Once you're on the helicopter, re-parenting can keep you on it and have lag comp work out nicely if you have it, but getting onto a moving platform is always going to be painful if it's already in motion.
lag comp requires you to rewind time in the same way that you do reconciliation right?
no
how does rust solve it?
¯_(ツ)_/¯
ye im jus asking if he knows some common solutions
I don’t know how they did it
But I know the options and what you loose with each. But it’s a bit complicated to explain, as it all starts by having a tick system in the first place (Burt does have one)
mine uses fixedupdate though, so I'm not sure if it's AAA quality
I have not played rust, so I’m not sure which compromises they opt for (assuming they are really server auth). And if they do lag comp (which I believe they do, every serious shooter has in one way or another), they gotta be loosing something
yeah i actually think they do have some form of lag comp. Just found something on it digging through their twitter posts
for lag comp, the server just needs the previous positions/rotations of all the colliders, rather than *rewind* things on the server, you can just buffer those in a separate list or whatever
I'm not sure if this is right, but on a really basic level of lag comp, you would just spawn the projectile at a different spot on the server?
based on ping time?
No
This is the tricky part
You have to have that, lol
A proper snapshot interpolation
"Hi Mr. Server, I was predicting tick 8 and seeing a 50% blend between ticks 5 and 6."
If you do, it’s the start
Notice what you are describing is fusion, overwatch and valorant style… there are other solutions
Like CS, etc
is this how photon quantum's prediction works
No
CS just has a fixed 100ms interp delay right? Based on measured ping, CS server estimates client's view.
I’m talking about their lag comp and even server input integration system
100ms frame buffer i thought but i really dont know
I said what joy described about a lag comp solution works for a tick model similar to the one in valorant, overwatch and photon fusion
But not in all others, although the principles are always similar
I like to think of lag comp like this. Client are seeing and shooting at stuff in the past. To compensate, the server can either spawn those bullets "in the past" or it can intersect them against past collider data.
that sounds fairly complicated to incorporate
I mean, you don’t have something like I’m predicting tick 8 in CS, I believe you have a time-ahead actually
Joy got me confused, when I asked about rewinding time, you said that doesn't happen, but I'm reading a bunch of articles about lag comp and they all talk about rewinding?
lol sorry
Here, the first way would involve something of a rollback on the server, yeah. The second way would just require saving historical collider data (and putting a BVH or something on top) and doing collision detection for spawned projectiles separately from other moving objects.
yeah I was gonna say rolling back every time someone shoots, might decimate server performance
if you have a ton of players
no doubt, you could probably align to the nearest tick and batch them, but yeah
pretty sure the second way you can test all projectiles at once
with physics projectiles, you're already aiming ahead of the player
so I'm contemplating just not even doing lag comp
I don't know
it's needed for consistency
otherwise the lead ahead amount would vary based on your ping
so if you send the interpolation info to the server, the server can tag each spawned projectile with a tick offset, say 4.5, which would mean "test against colliders as they were 4.5 ticks ago"
hmm alright
like for doing this collision detection, time is like a fourth spatial dimension
but I would only tell it to test, when the projectile hits something?
or every tick that the projectile is airborne?
the projectile is airborne until it hits something, right?
and you don't know if it hits something without testing
right
Hello. I wonder which one is a good practice?
Instead of writing bunch of query, I will get whole firestore document and turn them into object and loop and find what I want.
Thank you guys!
you'd put all this historical collider data in some broad-phase acceleration structure (e.g. BVH)
the tick offset is essentially a 4th spatial dimension (X, Y, Z, and now "distance into the past")
you'd test against the top-level hierarchies (basically the overall bounding box of each object that fits all its positions in time) and then interpolate during the narrow-phase
So maybe for every player, I could have a bunch of invisible "ghost players" attached to them, which are at the position of like the last 3 ticks or so of that player's position
and just check projectiles for those based on ping time or something?
using ping will have inaccuracies, but how many past collider (and maybe animation) states to store depends on the upper limit you're willing to compensate
so I'm in the right area-ish of understanding this?
idk lol
lmao
but yeah I see what you're saying, just save collider data for past ticks
that makes sense I suppose, assuming I'm thinking about it the right way
those "ghost players" I'm talking about would only be relevent to the server, and would be triggers that would only interact with bullets
and would just hold the position value of the player for the last tick, 2 ticks ago, 3 ticks ago, etc so the projectile could actually hit it, if it needed to
idk maybe I'm just spewing gibberish
communication is hard lol
old collider data that only projectiles are tested against on the server is definitely the right summary
alright then, I think we're on the same page 🤣
the projectile is still always spawned in the same place on the server right? At the end of the guns exact barrel?
if you do it this way, the server will spawn the projectile at end of the barrel, yeah
AFAIK the "compromise" is that where the projectile appears to be is "decoupled" from the old collider data it's actually being tested against
for most projectiles, it'll probably look close enough tho
might be possible to visually correct for that actually, idk
Hello! I am using Pun. Can i pass custom class in RPC as argument?
like this:
itemPV.RPC("SetItem", RpcTarget.AllBuffered, item);
Item Example:
Item item = new Item { itemType = item.itemType, amount = 1 };
You can, but you need to tell PUN how to serialize and deserialize it https://doc.photonengine.com/en-us/pun/current/reference/serialization-in-photon
Hello there I have a query about MLAPI.
I am trying to shoot a projectile spawning it from the server. The way I am doing it, the projectile is a prefab that I have included inside of the Network Prefabs list, and after I instantiate it, I call the Spawn() method on its NetworkObject component.
However, I do a few things to the projectile before I spawn it, for instance changing the velocity, drag, angular drag, etc, in its Rigidbody properties. Not only that, the projectile has a component written by me where I make sure its collider stops registering collision with the player character. The projectile's prefab has its collider disabled so that I get time to initialize it after I locally spawn it but before I actually enable it to move and collide, essentially.
What is the better approach using MLAPI to make sure the projectile and all of its properties (even what is enabled, what isn't, and how should collision be handled= get synced when I do .Spawn() ?
thanks!
Anyone with experience with Unity Headless(server build), for a 2d multiplayer game with practically only player moves and move checks is it costly to maintain?
Could any1 help with this, i am using PUN 2
#archived-code-general message
This is really going to be game dependent, you need to profile how much CPU and bandwidth each game session actually uses to find how many sessions you can run on what size server and look at the cost from there
why does this work
PhotonNetwork.Instantiate(
jumpParticleEffect.name,
groundCheck.position,
Quaternion.identity);
but not this
GameObject pellet = PhotonNetwork.Instantiate(
floopySnapPrefab.name,
shotPos.position,
Quaternion.identity);
does anyone know how to make behaviour based on an update function networked via mlapi?
im struggling here
i thought i might be able to just put the behaviour into a server/client rpc and call it every frame on the update function
that doesnt work though it seems
to be a little more exact
im instantiating a bullet which works fine on both server/client
but in the bullet script the update method is what "moves" the bullet
and that part doesnt work
Hello ^^ I'm having this wonderful error kind of out of no where... this results in players not being able to see and interact with each other online (only the local player controller prefab is instantiated)
any idea where this could come from ?
Hello there,
I'm working on a multiplayer game with MLAPI and I'd like to add a custom handler to spawn/destroy my objects over the network. The goal is to plug myself on the Zenject plugin to auto-inject my services and use Zenject's pooling system as well.
I see that MLAPI has changed its custom-spawning API between 0.1.0 and develop and I'm considering switching to develop to avoid having to change everything later. Does this seem like a good idea? If I want to do that, do I have to remove the 0.1.0 plugin and install the new one by modifying the git url, or is there a way to upgrade?
hey im using mirror and i cant connect on another pc. localhost is working
Have you port forwarded?
So the server application is running on my server which is a mini pc. i have port forwarded the standard port 7777 for udp and tcp
its in the same network so it should also work without port forwarding
You said localhost is working fine, so what's the issue then?
So, I can start 2 games and connect on my pc (localhost) but i cant start 1 game on my server and connect from my pc over ip
You used the correct ip and port?
yeah
Tried disabling the firewall?
wait lemme check but i think its disabled
yeah diasbled on both still not working
do i have to change anything in the network manager?
Presumably you changed the connect address
Yeah that's it
Well localhost is the computer you're on
So naturally, it won't work for other PCs on your network
yeah but when i host a server on my mini-pc and put in the mini pcs ip it should work shouldnt it?
or do i have to change it to the servers ip and make an extra build?
If you put in the correct IP, then it should work
so the server ip?
Yes, the IP you wish to connect to
okay and use that on both builds?
Well, when you're hosting the connection address is irrelevant
The client needs it though
oh yeah i was talking about the network address field in the network manager component
just using the ip doesnt work
Maybe I can show it to you in a screenshare or sth?
Screenshot the network manager
I guess you could try putting the server IP in the network address field, just to be sure
and use that build on both devices? or just the server?
The client needs to know where to connect, whether you use it on the server is totally irrelevant
i actually give the information to the client by typing in the ip here
in the game hud
the network address field here is just what is being filled in here first
nope
Then it should work fine
hmm weird
wait
i think its kinda working
when there is no server running on localhost and i try to connect i get errors but when i try to connect to the server which is running i only get a timeout
so i think its not like hes not finding the server
is kcp transport correct?
Yeah it should work
could it be the port?
Are the ports the same?
ye
As you said, you don't need forwarding to make an internal connection
hmm
Hello ^^
I'm using PUN2 and I'm trying to add a return to menu button, but I'm having some trouble, PhotonNetwork.LeaveRoom(); and PhotonNetwork.LoadLevel(0); won't cut it, I get a strange error :/
I can go back to the menus and everything seems fine in the menus, but when I try to launch a game, it doesn't instantiate a player and gives the scene camera view
I turned on Statistics GUI and checked sth. When i connect on my server it actually sais connections: 1
tho i'm getting a timeout
do i need to use AWS?
No, that's just a server like any other
Is there any good tutorials on incremental games with playfab?
Anyone in here ever tried predicting wheel collider cars with rollback?
Hello. I have written some back end in the unity with Firebase. and I want to write an API and publish it as web api. but do not know where to start
Is unity a good for writing API (ASP.Net)
or should we just write all back-end in .net?
and create a WebAPI project inside the solution?
up ^^ (so sorry for being insisting, it's for a school project and the deadline is coming fast, I'm getting desperate on this :/ )
I cannot syn shooting time and character rotation. For example, a remote player or remote bot shot at the player then rotates towards the player
Transform data and shot data are sent from server to clients as snapshots in fixed time.
Snapshot-> TransformData,ShotData,etc.
I compute interpolation time and interpolate rotation and position and after that run shooting action but it does not solve the problem.
I think the problem is about ordering packets
For example first packet 1, packet 3 and finally packet 2 are received. Suppose in packet 2 shooting happens
its really hard
It looks as if your code (button-reaction?!) calls LeaveRoom, then attempts to do some action which relies on being in a room. That is the root of the problem here.
It's sadly a bit tricky to help here, as this depends on your game logic...
found the issue ! I needed to destroy the room manager ^^ But yeah it's a bit tricky to explain accurately how things work without explaining every thing :/
And I just noticed you are everywhere related to photon !
Thanks for the help ^^
Glad you found it!!
Yes, it had to be something like that. Often setup of prefabs and scenes are as important as the actual code on components.
You are welcome.
Which database to Save Leve, Wins/Losses or Money ?
I need to decide if i should use PostgreSQL, MySQL or some other Database.
I will soley use it to save a Players Level, Money and stuff like K/D & W/L
It should work with C# as that is what i know and Unity uses
Do you want to make it cheat avoided, so you would use a server or do you want to just store it locally, then you could just serialize a file per user for example.
Server, its money, level and rank etc
needs to be safe
Oh alrighty, than I would just go with some headless cms and use endpoints to feed in the data and sync with it, dealing with tokens and so on. I am using directus today a lot, its headless and just fun to work with, but my app is heavily content based. Also worked with plesk for data, but not a big fan of it.
Ive heard plenty of times that MySQL should be enough
but i should worst case test it
and if its not good enough im directed towards directus
so youre the second one confirming directus
Always balance out crazy tech with the users you gonna have on the game, no need for crazy anti cheat thing if the game might have only some dozen users for example.
you just make webcalls to enter the endpoints of directus
so id have to convert it to js webcalls, which is a bottleneck
does it accept Linq webcalls ???
pretty sure its just JS
not C#
ohh linq.js
ok
i still dont know js
is the problem
xD
it should be ok with C# Linq or C# calls
Im out for today, keep us updated what you tested 🙂 js and c# is like super easy to compare and adapt from my pov
so directus aint working i guess
js works completly different
lol
JavaScript is a prototype-based language, C# is Object-oriented
JS actually confuses me
You do you 😉
Hi, I'm making a 3d online multiplayer game(I'm using photon, PUN 2, for networking) but I'm having a problem, when I run two clients on my pc, they connect into one room without any ishues, but when I tried the game with a friend, our clients didn't connect, can someone please help me solve this?
You should debug log the errors, i guess it might be a port issue, but can be something inside your script too
I didn't get any errors in the console
I suspect, that my main menu script causes this ishue to happen, I'll send that in tomorrow, because It's pretty late where I live right now
okay, help
if a localplayer has a variable how do i synchronize that across every client?
@calm hinge Send a packet that contains the change and the ID of the object 😛
Happen to be using some sort of networking library?
mirror
Well in that case you don't necessarily have to send packets yourself 😛
https://mirror-networking.gitbook.io/docs/guides/synchronization
i tried a SyncVar and it's only half working
Note:
Data is not synchronized in the opposite direction - from remote clients to the server. To do this, you need to use Commands.
for whatever reason commands don't seem to be working properly
Make sure to read the documentation for them in case you are missing something. Probably wanna hop on the Mirror discord for more help.
alright
from what i gather i need to use a [Command] to tell the server about the change
but then i need the server to tell every other client about the change
that's where i'm stuck, i'm not really sure how to make that happen without setting up dedicated functions for every single variable i want to communicate between clients
Sounds like you could use one of those SyncVars for the second part?
when i'm trying to send a variable from one player to the rest, the variable only shows for the local player even though it's sent through an RPC
@weak plinth don't you have to send it through a serverRpc
Of you want to update it for all?
(No clue tbh still new to it) 🤣
Yeah that’s alright, I just trailed and errored the everloving heck out of it and it managed to work
Thank you anyway tho
And have it as something that's a networkVariable of some sort that will change for everyone
Nice nice ^^
This the script, that I suspect causes my issue
that's my issue, help is very much appreciated
I've heard that Server Authority, Client side prediction. In a physics game is a bad idea? Is that true? Should I have it be client authority?
you can do CSP for physics based based. Photon's engine Quantum is entirely built around doing prediction for everything in the scene, including physics.
physX is not great for prediction, since it is not designed for it. But depending on the project it may work for you. Fusion is a new tool in beta from photon that allows for prediction of physX rigidbodies (and any other kind of networked object)
Also important to mention Rocket League is all built around that concept...
So it's not a bad idea, just hard to execute well.
Isn't there a way to stream audio/video from my streaming server into unity? The VideoPlayer included can only play videos like mp4 hosted somewhere but no realtime streaming HLS / RTMP, the assets in the store are outdated / bad review / very expensive etc .....
I guess you gotta go with the very expensive, if you want something well built, I am using AVPro for example. Not sure if you can just download from the server and save it to disk and stream it then inside your player. But are you sure, the built in one does not support URLs?
it supports URLs, and it works if I have an mp4 file somewhere. but I have live-streaming server with RTS / RTMP protocol and this does not work
for example i live-stream my desktop / gameplay and wan't this as stream in the game
not a "static" mp4 file somewhere
Ohh got you, static but on the server, sorry, missed that part, hm, never done that, sorry, there seem to be some plugins out there
Photon question: every time the player dies, I call this code
string key = PhotonNetwork.CurrentRoom.CustomProperties[PHOTON_VAR_TEAM_DEATHCOUNT + teamPhotonID].ToString();
int deaths = int.Parse(key);
deaths++;
Hashtable hash = new Hashtable();
hash.Add(key, deaths);
PhotonNetwork.CurrentRoom.SetCustomProperties(hash);
but the value is zero every time, how come?
Did you debug all values to check if you get the right ones?
Uh, now I see I'm using key as a value and as a key
ok works now, sorry for the false alarm
Hello! I am using PUN. Is OnOwnershipTransfered callback is called when any transfer occurs in the scene? so its not connected to the script and i dont need to duplicate this callback
Exactly. The method parameters will provide which PhotonView is being changed for each call.
so pontentially this call body will grow up and that is ok as i cant divide this?
The alternative is to implement IOnPhotonViewControllerChange for callbacks from a specific PhotonView. You'd have to photonView.AddCallback(...) and photonView.RemoveCallback(...) per view.
i am using mlapi for my multiplayer game however when i start the server or client my players arent spawning in
nvm i was opening the wrong build so that is why it didnt open
however now im getting a different error
something with your GFX
can you rephrase it?
Whats your ggraphics card?
There seem to be some issue with it, as it does not seem to find, recognize it? never seen that error before, just reading from it
Yeah maybe jsut a false system thing, close everything, update the driver, try again
doesnt seem to be the case should i ask it on a different channel?
it works fine in the unity editor now
but i cant open it
i cant build and run it*
ok i figured the problem is in my build settings i have server build enabled
Oh well yes, that def does not have any gfx card 😄
hate it when u spend hours on a simple mistake but thats programming for you
how do you spawn a object in mlapi on client
it says only the server can spawn a object
have you read the documents?
a little bit
Unity MLAPI is a mid-level networking library built for the Unity game engine to abstract networking. This allows developers to focus on the game rather than low level protocols and networking frameworks. All this is provided for free under the permissive MIT Licence by Unity and the MLAPI collaborators. MLAPI is open source with no attached cos...
this is the one im following
let me send you a video as well
This is part 2 of the series covering basic multiplayer in Unity3d using MLAPI.
Full Playlist HERE:
https://www.youtube.com/playlist?list=PLbxeTux6kwSAseRmJeCyvkANHsI16PoM6
In this part we make a simple First Person Controller from scratch and add the components and code that it needs to work across the network.
This includes the how and why we...
im following both
video part is clearer since you can see how to do it
so i should folow this video series?
its very basic stuff i just typed unity mlapi on youtube
and found this
but you can probably find more stuff for mlapi too
if anyone has a better series please do share it with us
the servers' character camera is disabled even though i am disabling all of the other hosts' camera. Works fine with the client side character but not with the server
in here i handle the player character controller getter in the start function
i should probably encapsulate the double jump and the movement but ill do it when i actually get it to work 😆
What do you mean, that is how it works?
any way to make that the host can host a server and other players can join with the ip of the host
camera of second player is attached to the first player. The server client doesn't spawn a player. If anyone could check the code please do inform me if you know how to fix it. I am using cinemachine with mlapi. Here is the code: https://hastepaste.com/view/wHh9f
Your question does not make sense, to join any server you need an IP
If you're asking how to do networking in general, that is too broad a question for this channel, and some self-lead research would be needed
like you can connect to the hosts server that they are hosting with there pc
I've no idea what you're on about
If you have a client, they can join a host by IP if the host has port forwarded
like the host creates a server with a custom id and everyone can join the host using the id
like without port forwarding
Well that would require some sort of server list, where said custom ID can be matched with the host and their IP
That is where you'd need a relay server or punch through
can i do it with mlapi
You'd need to look into that
I remember seeing some sort of Relay options, not sure how you'd utilise them
is there any way to host a server on a hosts pc?
Yes...
how
i been looking for that
Then you have not been looking well enough
Tutorial that explains adding scripts to objects, editor modes (Host Server and Client), basic player movement,Permissions and basic RPC use.
There's the MLAPI docs
time to study it lol
ill just reask the question like this because its been pushed up quite a bit e.e
anyone got any news tidbits on DOTS networking updates?
Hi! A question about pun: if I place some objects in the scene, next player that joines has his own again on that place (duplicate it), how can I avoid it?
Scenesync is true
I made multiplayer game with clients and dedicated server and this works nice for windows but webGL version doesn't connect to server? i need networkmanager to use sockets or something?
and the exact page in unity manual i am looking for is not available??
@ancient cypress My understanding is that WebSockets are broken in MLAPI atm. I would ask in the MLAPI server.
i just made a game using MLAPI but it works only on my machine (localhost)
how can others play it online? games like csgo,muck u can just host a server by a click and others can join u
@hexed hatch CSGO private lobbies are most likely using Valve's servers. Server hosting generally requires port forwarding or relaying
Odds are starting a dedicated CSGO server isn't going to work out of the box
i managed to fix my problem by getting the child components and setting the follow and look at properties of the freelookcamera to the child component
Hey guys, quick Q; what would be the "correct way" to start server on the networkManager on scene load? If I do it from Awake on a gameobject in that scene, the NetworkManager.singleton.StartServer(); the singleton here == null
when u host a game incsgo ur ping is 0
i think its not hosted from valve dedicated server
how do i get islocalplayer mouse position
Well the script getting the mouse position will always get that instance's mouse position...
You would use IsLocalPlayer in somewhere like Start or Awake to disable the component if this is not the local player
like i got the local mouse position but the object of the other mouse position is rotating to the first mouse position
Then both objects have that script enabled for each client
Client A should have Client B's object's mouse script disabled, and vice versa
You could also use a check before any form of movement if you need to keep the component enabled
like i want the both clients rotate there object to there mouse position
do i need to do seprate scripts for mouse rotation
No, lets take this from the perspective of client A
So on client A, we have two objects, client A's player, and client B's player
On B's player, we want to disable the component causing that rotation (or hide the rotation behind a check like IsLocalPlayer)
Because the NetworkTransform should handle the updating of B's rotation for client A's game
i still dont understand how can i make that the a client rotates there mouse position and b rotate to there mouse position
Well rotating a player to a mouse pos is a well documented thing, Google it
it rotates both of the objects not one
im trying to figure it out how to do it
Well, in the NetworkStart function, check if this is the local player, if not disable the component
Or, if you need to keep the component enabled for a network var. Wrap all the logic inside an if which checks if this is the local player
THANK YOU!!!!!!!
Hey friends, I was working on "cleaning" my project, and I didn't think I touched the network code, but probably messed up some scene data, but regardless, when I go from the main menu area to a lobby, it always claims I'm not the master client, even though there are no other players in the player list. I'm h oping that someone will say, "Ohhhh, did you forget X you silly goose?"
It was working a few commits ago, and I forgot to test intermediarily.
PS: This is PUN
I just logged every callback in my GameManager and isMasterClient is always false
MLAPI or Mirror
I think I got it
What would be the proper way of cross-initializing my objects with MLAPI, when I have fields that I just want to initialize when the object is created and have no need to track later? I could use NetworkVariables with callbacks but it seems a bit overkill for something that will just be set once. Is it a good idea to use RPCs for this type of things? I'm doing a RTS-style game where you cannot join mid-game.
One of the reasons I ask is that RPCs seem to not be called when I just spawned my objects, I guess the network is maybe not initialized at that point yet or something, I'm wondering if it's worth pursuing in that direction, even if it seems a bit cumbersome to add OnValueChanged callbacks on all the fields that'll just be set once.
If you are sure that you need no late join you can use RPCs. Make sure you call them in NetworkStart and not in Start or Awake
Is MLAPI usable? Use: Multiplayer game with two teams.
Is there documentation yet or a guide on how to set up client hosted network for a small game using unities mlapi?
how do I get my "AppID" for the XboxServices.Config file in the Xbox Live unity plugin?
Hey guys, I was fiddling around with a few different networking solutions (MLAPI, Photon namely) while doing 3d stuff but is there any difference in how they each perform in a 2d environment?
or are there any other solutions that are best fitted for 2d networking?
Hi guys, question about a relay server.
I have a Relay server, with all clients connects to this server, and the relay server make that all messages of every client are replciated to another. Any know any example/github repo for see how manage the broadcast to another clients?
Hey, so i'm wondering if anyone can help me with a question. So I'm using Photon and I have this item in my game that my players can catch off the ground. If the player goes to it and interacts with it it will disappear and i wanted to have it respawn somewhere else. The way i was thinking to do this was to just have a photon view inside the gameobject and then call a RPC function that would tell the respawn coordinates and instantiate a new gameobject with the item prefab, but then i remembered that the prefab uses a photon view and now the logic is all jumbled up in my head.
What exactly spawns what in these conditions? Is the server respawning the object or is each player because the RPC function is running for each player. Does it mean they are different instances for each player? How can i spawn the thing and have the object be the same for both with the same photon view?
If anyone can clarify this to me i'd be grateful because my head is up in water from trying to figure this out as i haven't fully understood photon yet and the documentation seems to be a bit confusing to me
Yes the joining system would be similar to Starcraft/Warcraft/almost any RTS. All players join when the game start and if someone drops he's out for good.
Okok, I tried to do it in NetworkStart at some point but i'll try it again then, there was probably something else messing with it.
Thanks for replying