#archived-networking

1 messages · Page 116 of 1

wet compass
#

this is happening to me too, other weird things ive run into with networklist is that its Contains() method seems to return the opposite.

runic rampart
#

Regarding your second point, that is fixed in pre 5 Fixed a bug where NetworkList.contains value was inverted (#1363)

wet compass
#

oh cool, thanks for that

#

as for call dispose ondestroy, is that in the networklist script in packages or wherever we use a networklist?

runic rampart
#

wherever you use a network list I think, hopefully someone can confirm this for me

#

we're doing

            if (_networkedAttributes != null)
            {
                _networkedAttributes.Dispose();
            }
#

_networkedAttributes is a NetworkList

#

I don't know why NetworkList doesn't use a finalizer to clean up the memory on its own

wet compass
#

thanks!

mortal trellis
#

Is this netcode stuff only or are mirror questions ok here?

hearty dock
#

All networking related questions are welcome here

alpine cedar
#

what's up gamers, I'm having an issue where the ingame playertag for my multiplayer isn't seen by other users. I have a script called gettext, it gets the text from the input. I also have a scrip attached to the player called settext, it basically just takes the input and replaces the TMP child's text with the inputted text. It works on the client's end but for some reason on the server end, / other player's dont see the updated text.
here's the code'https://pastebin.pl/view/ca3c4b41

quaint moon
#

I don’t understand how a server hosts a game. On Playfab you set up a .exe (a build of your game) to execute when a lobby is opened on your dedicated server. But how does the server know what scene to open, know not to load in a player for the server, get past your loading screen/main menu, know to ignore everything related to a player/requiring input

#

Or does your server build of the game need to be completely different then your client build

alpine cedar
reef jetty
#

i want to add teams to my game in photon pun 2 can anyone help??

#

please

#

my project has stopped due to that

#

cause i cant find a tutorial

shadow spoke
#

make a team manager

#

Then on join the match, add them to the manager, on leave, remove

#

Not that hard, only question is what to do when teams are full or you want load balancing

#

Tutorials will only get you so far, you will need to take over from there.

shadow spoke
#

In mirror, you’d send a command, then a rpc back to set it.

peak trout
#

Hey, what would be the best networking solution for chat? I'm thinking about php & sql but any others options like sockets are welcome. Also it have to works on Android devices.

pliant sundial
quaint moon
austere yacht
frosty crystal
#

Hello!

#

Do you have any rds diagram for multi choise question system?

#

how should I model?

pliant forum
#

Hi, How could I sync a list of game objects? Does it work if I use SyncList <>? I use Mirror for networking

sharp pawn
#

Hey, I'm having a problem with (probably) NetworkTransform. It seems to prevent joining players from moving, but if I join from the editor and disable it, i can normally move the gameobject. Then if i reenable that component, it snaps back to it's original position. Any ideas what might be wrong with this?

#

If I host in the editor and join from the build, i can freely move the player gameobject, but the client cannot move on it's own. I think I should mention I'm using Unity Netcode.
Edit: I've just checked whether it's not the fault of my player controller, but it seems that input are working as they should, it's just position not changing at all.

verbal lodge
sharp pawn
# verbal lodge Can you share the code you are using to move the player?

Well, since player is a car, i just apply motor torque to the wheels and it works.

leftWheelsC[0].motorTorque = m_verticalInput * actualMotorForce;
rightWheelsC[0].motorTorque = m_verticalInput * actualMotorForce;```
It does work and it does move the player if I disable the NetworkTransform and change Rigidbody back to non-kinetic (because NetworkRigidbody sets it to kinetic).
Other than that, player's position isn't modified in any way
verbal lodge
clear bridge
#

Hi, which is the best way to update clients' rotation in Netcode? I have a joystick and I'd like to apply the rotation of the joystick on the right to the client

sharp pawn
ocean cradle
#

So I am working with Mirror and have written a script to deal with the local player’s viewmodel and playermodel, the issue is that it does not work and Idk why, here is the code:


public GameObject Playermodel;
public GameObject Viewmodel;

void OnClientConnect()
{
if (isLocalPlayer)
{
Playermodel.SetActive(false);
Viewmodel.SetActive(true);
}
else
{
Playermodel.SetActive(true);
Viewmodel.SetActive(false);
}
} 

shadow spoke
#

Uhh

#

Of course that’s not gonna work.

#

Going from the snippet you provided, you don’t inherit from NetworkBehaviour, and OnClientConnect etc are required overrides.

#

That, and OnClientConnect is probably the wrong thing to use, I’d use OnStartClient because that is called once the client player object is actually initialised

ocean cradle
#

Okay, thanks, anything else?

shadow spoke
#

That should work…?

ocean cradle
#

Aight thanks

alpine cedar
#

photon not showing tmp text of other users

#

i instantiate the tmp right after spawning the player

#

and it works on the client end but other users cant see it

cyan pebble
#

im attempting to make a simple 1 on 1 turn based game and the current plan is just to get 2 people able to join on any order

is there anyway of knowing whether there is a host, and if not then start hosting, otherwise connecting as client?

such that if 2 people join a game nomatter what order they join theyll be able to connect and game will start

id rather not have a seperate Server running

#

the current rough setup of the code is like this atm

stoic salmon
#

Hey !
How to Synchronize My world for all players using mirror in unity

distant bolt
#

Mirror also has a discord you can ask in which is pinned to this channel

stoic salmon
#

?!

somber minnow
#

using netcode, how can i check if connection's established for a client? wanna do error message if could not connect and proceed to lobby if its ok

patent fog
patent fog
#

it's old version though, don't know if still applies

#

also there's some callback on connect and disconnect, but can't check for sure (didn't find it in the latest docs after a quick search)

somber minnow
#

Thanx

ocean cradle
#

I came here before and needed help, I did the changes but it’s still not working so I think the issue is with the setting up or I did something wrong here.

I have the script attached to the player, and put the playermodel and viewmodel into their gameobject places.

using UnityEngine;

namespace Mirror
{

public class PMandWMfixer : NetworkBehaviour
{

public GameObject Playermodel;
public GameObject Viewmodel;

void OnStartClient()
{
if (isLocalPlayer)
{
Playermodel.SetActive(false);
Viewmodel.SetActive(true);
}
else
{
Playermodel.SetActive(true);
Viewmodel.SetActive(false);
}
} 
}
}
jade hinge
#

how do i create my own udp system for an fps not using mirror or any other programs like that then integrating it into steam

cedar zenith
ocean cradle
#

I have haven’t I?

#

What-

#

No I changed it to that

#

Forgot to change it in the reference but when I did it still failed

cedar zenith
#

that's still not overriding the base class's virtual method...
here's an example

public override void OnStartClient()
{
}
shadow spoke
#

Although I hope you know what you’re doing, because you are about to enter the raw API world where you have no luxuries of having an high level API handling stuff for you. You better know what you’re doing and understand a large amount of networking or you will fail.

#

Also, I would NOT recommend making your own UDP implementation unless you know what you’re doing as well. There will be a lot of topics that are complicated and have many ways to solve the issue. You’re much better off looking at existing implementations like Litenet, etc if you’re going to use a system that utilises raw UDP.

#

Making your own UDP implementation for development and research purposes? Cool. But you better test the shit out of it when you even want to think about putting it so the public can test it

#

Take this with a grain of salt, keep the warning in the back of your head, be prepared for the uphill challenges of making your own UDP system.

shadow spoke
#

@ocean cradle , don't define your code inside the Mirror Namespace as it will cause lots of confusion later.

#

Instead, do something like this:

#
using UnityEngine;
using Mirror;

namespace OiranStudio.BoobaShooter { 
  public class SomeCharacterScript : NetworkBehaviour {
    // ...
  }
}
#

If you use ASM Defintions, which you should learn how to use as they help keep your code seperated than one stupidly huge assembly when using Mono, then this becomes very useful

#

using Mirror; tells the C# compiler that you are referring the Mirror namespace, and hence "give access to the goods contained within"

#

while namespace Mirror means your code lives inside the Mirror namespace. Allows you to access Mirror components very easily, but causes complications.

#

I always recommend, at bare minimum, having a namespace of MyGame or some project name (or codename, for example the one above)

weary quail
#

Heyyy lovely people!

I want to trigger a event inside of unity from a website. How can I achieve this?

I can’t find no step by step practical method on this on the Internet.

#

For example if I press a button on my website, I want my cube to be destroyed in unity.

sullen basalt
#

yo is this a glitch or something because I imported PUN 2 into my project but when I look at my project packages Pun 2 is no where to be found

shadow spoke
#

@sullen basalt any compile errors?

sullen basalt
shadow spoke
#

Photon 2 is not under packages in the inspector. It’s usually installed via UnityPackage, not a Package from a repository via UPM.

shadow spoke
spring crane
shadow spoke
#

Yes and no, actual packages appear in your project folder inspector under Packages. assets, from the asset store, do not - they get imported into the project folder.

#

They show up in Package Manager, yes

spring crane
#

Oh I see, misunderstood the topic.

shadow spoke
#

All good

#

Oh shit, didn’t realise you were a mod

#

Now I feel bad for saying “no, wrong” 😛

spring crane
#

The answer was good though 😄

warm musk
#

hey im having trouble with photon multiplayer and im hoping someone could help me with it
heres the code https://gdl.space/ubamaxicuw.cs
i have two different issues. one is that i get the following error when player 2 joins in https://i.imgur.com/uCE0K1t.png
My second issue, and the weirdest one, is that when player 2 joins the game they destroy gameobjects and make references show up as missing. Basically in another script I create 50 humans and assign them houses and locations (also GOs) and set their parent to be an empty GO named "Humans". If I set humans to not destroy on load then when player 2 joins they will delete the references the people have to their homes and current locations. If I do allow humans to be destroyed on load then when player 2 joins they will destroy the empty humans parent and take all the humans along with it. Either 50 people go missing or they become homeless. Tragic. I've been stuck on this problem for days now so any help would be appreciated.

upbeat wadi
#

Does anyone know all the pros and cons when it comes to "Photon (PUN 2)" and "Mirror", I see that Mirror is more optimized for full on MMOs but a lot more complex to maintain, and PUN 2 is a lot simpler to use but has very limited CCU (concurrent users).

austere yacht
# upbeat wadi Does anyone know all the pros and cons when it comes to "Photon (PUN 2)" and "Mi...

PUN is non-server-authoritative aimed at max 16 friendly CCU and short uptime, which allows it to be simple. Mirror aims at being a general purpose netcode stack with server authority and able to represent close to everything you might need up to 200 CCU. However, anything above 16 CCU requires you to think hard what you are doing no matter what library/service you use. Mirror can also be used with shared authority. Neither is a solution fully capable of running a MMO out of the box.

shadow spoke
#

Pretty spot on for a summary there Anikki

#

Although PUN charges for bandwidth and messages per second

#

if you exceed a limit per second, then you'll get lag or messages get dropped

austere yacht
#

I’d consider PUN a prototyping library/service at this point

shadow spoke
#

PUN is a great choice if you need something in a hurry, but it is not ideal for an shooter or something like that. You could use PUN for a very basic VR chat thing with your friends

#

Mirror is focused towards MMO usages but it does support general workload. There's also Mirage that aims to be a "all round" solution that started as a Mirror fork.

austere yacht
shadow spoke
#

Ah, you talking about the MMORPG asset?

#

If so I know the one you mean tenryuuSmug

austere yacht
#

No

#

Talking in general, mirror can do mmo because it doesn’t lock you into a particular way how state sync happens, you have source access and can implement custom messages

shadow spoke
#

Ah yeah

austere yacht
#

no idea how stable it runs with 23h uptime and getting hammered with 200 ccu

shadow spoke
#

yeah that's a good question

#

AFAIK the stress tests that Mirror has gone through haven't hit one day of activity

#

It would be a nice test to have a 24 hour stress test that has 200 headless clients doing stuff automated

austere yacht
#

Also they are tests and not an actually running mmo of relevant scale

shadow spoke
#

Yep

#

The lead devs' weapon of choice for CCU tests is uMMORPG (probably since they program it too)

#

but even then, uMMORPG doesn't have all the features that players would use in a MMO (then again I don't play MMOs, but I know some MMOs have like 3 rows of hotkeys and spells/magic and buffs and debuffs etc)

#

Ideally you'd want to have a small world with a bunch of playable things and have 200 players moving around and doing stuff over 24 hours

#

that, to me, is less synthetic and more real-world testing

stiff ridge
stiff ridge
shadow spoke
#

well there you go.

#

good to know

rocky garden
#

hello @everyone new here can anyone help me with photon

#

im having an error saying duplicate photon id

honest stump
#

hey guys, Im trying to figure out what networkengine i should use. As i read, Photon only can have 20 people in an application and mirror has a larger scale connection. is this true? My goal is to make matches with 4 players and have a server list, but mirror doesnt support server lists. what should i use?

#

or should i use steamnetworking?

hardy citrus
#

How should the code look like when connecting to a steam lobby? I have troubles understanding what I need to do.. Tried several examples but doesent work anygood with my setup (Netcode + Steamworks)

It works fine creating a lobby and get the player object.

Heres the code that the client will run

    void OnLobbyEntered(LobbyEnter_t result)
    {
        lobbyID = (CSteamID) result.m_ulSteamIDLobby;
        if (result.m_EChatRoomEnterResponse == 1)
            Debug.Log($"Successfully joined lobby {SteamMatchmaking.GetLobbyData((CSteamID) result.m_ulSteamIDLobby, "name")}!");
        else
            Debug.Log("Failed to join lobby.");

        int playerCount = SteamMatchmaking.GetNumLobbyMembers((CSteamID) result.m_ulSteamIDLobby);

        // Join host's game directly
        if (playerCount > 1) {
            var ownerSteamID = SteamMatchmaking.GetLobbyMemberByIndex((CSteamID) result.m_ulSteamIDLobby, 0);
            hostSteamID = ownerSteamID;
            StartClient();
            Debug.Log("Starting client hosted by: " + hostSteamID);
        }
    }

    public void StartClient()
    {
        
        if (NetworkManager.Singleton.IsHost)
        {
            Debug.Log("Hit Lobby Entered by server");
            return;
        }

        NetworkManager.Singleton.OnClientConnectedCallback += ClientConnected;
        NetworkManager.Singleton.OnClientDisconnectCallback += ClientDisconnected;

        NetworkManager.Singleton.GetComponent<SteamNetworkingTransport>().ConnectToSteamID = hostSteamID.m_SteamID;

        NetworkManager.Singleton.StartClient();
        
    }

It get the room name and host id, but wont do anymore.

dense leaf
#

how to get client id of game object in netcode?

ocean cradle
#

So it seems that the way I’m using playermodels and viewmodels is insufficient, everytime I test out the game through 2 players, one of my characters only show the viewmodel, with the other only shows the playermodel, to make matters worse, it stops my movement script as well

ocean cradle
#

Nvm my movement script is the thing that does not work here

clear bridge
#

How can I assign the "Animator" variable of Netcode's NetworkAnimator from the inspector in a prefab? I can't do it and it gives me this error

shadow spoke
#

Use a GetComponent call instead in a script @clear bridge

shadow spoke
#

PUN is quick to get started. Mirror is more tranditional server based networking stack, and requires some extra time and effort.

#

If you’re just doing teams of 4 then it really is a question of what stack you want to use, because 4 players is literally bugger all in the network side of things.

#

Just keep in mind that PUN will charge you for CCU, while Mirror is free.

honest stump
#

ow i see

#

i dont have a budget, so pun will not work for me i guess. But why is it that 4 players in a match is a bugger?

shadow spoke
#

What I meant by the bugger comment is that 4 player game would be pretty easy to do over the network

#

Depending how complex your code is

honest stump
#

ow

shadow spoke
#

In terms of PUN/Mirror stressing out

#

I mean, you wouldn’t use PUN for Battle Royale, for example. Mirror has done BR.

#

Anyway, Mirror is probably your best bet

honest stump
#

okay, thank you so much! i've got a better sight of it now.

shadow spoke
#

Good luck. Check out some of the examples that come with Mirror and take a gloss through the manual

#

Networking is hard, but Mirror aims to ease some of the pain

honest stump
#

Ill try my best😃 . btw, did u mean nodejs instead of nodels?

clear bridge
shadow spoke
honest stump
#

ty

shadow spoke
#

You’re welcome @upbeat wadi

shadow spoke
#

You could always wrap the animator stuff inside a null check

#

Which would squash the error

#

Oh wait

#

NetworkAnimator…

#

Okay so if you’re wanting to do that

#

Open a empty scene

#

Grab the prefab and drag it into the scene, then assign the network animator stuff, then zero out the XYZ position, select apply changes to prefab on the inspector, and then delete it from the scene view. That should make the changes stick.

clear bridge
#

ok, I'll try to do that

shadow spoke
#

In the inspector, you can drag the object itself into a field iirc

#

It would then automatically grab the reference it needs afaik

clear bridge
#

it works, thanks

ocean cradle
#

The code In using for my movement is breaking my game because, once more than 1 player joins the server, it freezes the players and the other scripts break too```using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Mirror;

namespace TFT.Controller
{
public class FirstPersonController : NetworkBehaviour
{
private float yaw = 0.0f, pitch = 0.0f;
private Rigidbody rb;

    public float walkSpeed = 5.0f, sensitivity = 2.0f;

    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        rb = gameObject.GetComponent<Rigidbody>();
    }

    void Update()
    {
        if (!hasAuthority) { return; }

        if (Input.GetKey(KeyCode.Space) && Physics.Raycast(rb.transform.position, Vector3.down, 1 + 0.001f))
            rb.velocity = new Vector3(rb.velocity.x, 5.0f, rb.velocity.z);

        Look();

        if (Input.GetKey(KeyCode.Escape))
        {
            Cursor.lockState = CursorLockMode.None;
        }
    }

    private void FixedUpdate()
    {
        if (!hasAuthority) { return; }

        Movement();
    }

    void Look()
    {
        pitch -= Input.GetAxisRaw("Mouse Y") * sensitivity;
        pitch = Mathf.Clamp(pitch, -90.0f, 90.0f);
        yaw += Input.GetAxisRaw("Mouse X") * sensitivity;
        Camera.main.transform.localRotation = Quaternion.Euler(pitch, yaw, 0);
    }

    void Movement()
    {
        Vector2 axis = new Vector2(Input.GetAxis("Vertical"), Input.GetAxis("Horizontal")) * walkSpeed;
        Vector3 forward = new Vector3(-Camera.main.transform.right.z, 0.0f, Camera.main.transform.right.x);
        Vector3 wishDirecton = (forward * axis.x + Camera.main.transform.right * axis.y + Vector3.up * rb.velocity.y);
        rb.velocity = wishDirecton;
    }
}

}

shadow spoke
#

Protip, please use a paste in service like pastie or hastebin than huge code dumps, makes it lot easier to follow too 🙂

#

I do t see anything wrong with that tbh, you’re using hasAuthority and looks OK

#

How does it break? Error messages? Stack overflow?

ocean cradle
#

Oh, alright I’ll keep that in mind, and it dosent say it, but basically when I tried to use 2 players in the server, the characters froze and the pervious code that made the playermodel and viewmodel split stopped working, with both not having their playermodels and only the guns.
I tried to check if it was a problem with the playermodel script or the movement script, and once I took the movement script off, the playermodel script started working again so I’m not sure

shadow spoke
#

Chances are you had a race condition or something

#

But hmm

#

2 players as in 2 clients, or 2 players 1 client

solemn haven
#

Hello, can you help me? I want to convert json to object

#

This is the json file

#

and I have this error. what's the problem?

ocean cradle
shadow spoke
#

wrapper can be as easy as

#
public class JsonBubbleWrap { 
  public Whatever thatThing;
}
solemn haven
shadow spoke
#

ugh

#

Let me look up my warchest

solemn haven
#

that is one big array.

shadow spoke
#

Try that

solemn haven
#

ok, thanks

shadow spoke
#

Otherwise IDK

#

Json can be a pain in the ass and also a blessing

solemn haven
#

it didn't work

#

1,2,3.... are the names of the object?

#

mmm

#

that way works for arrays like that::

solemn haven
# solemn haven

what kind of array is this... can anyone help? how to convert it to obj

ocean cradle
#

Oh wait, 2 players 1 client

shadow spoke
#

or you mean the editor and the built client?

ocean cradle
shadow spoke
#

dunno then

ocean cradle
#

Oh

#

Welp, thanks for help with the other stuff them

shadow spoke
#

Pretty sure there'd be a tutorial out there for Movement + Mirror

#

I mean, I could write code that would work but eh

ocean cradle
#

So I fixed it, very vague but I was able to find someone who showed me what to do, thanks

solemn haven
#

it gives me emppty string. why??

#

I've googled and they said something about certificate and root. Idk

hardy citrus
#

Do i have to do something special when i connect a client
Player prefab creates fine when i start host, but start client wont create any player prefab,
Im using steam matchmaking

trail parrot
#

Hi all

Anyone have made/tried a game with large map size, networked? Say i use the Floating Origin Ultimate asset (which supports networked, but server side, unit position is still unchanged), what would be the limitation, or recommened network design?

#

Currently in my understanding, if i use a origin shifting client side, then the best case is to do fully peer2peer, client auth phys queries for every checks needed around that client

#

But.. what if i still aim for server auth? Is there really no hope?

shadow spoke
#

It can be done... the question is how much time and effort do you want to put in to make it possible?

trail parrot
#

It depends on how much time/effort is needed hehe

weak plinth
#

What would you say is the best Networking solution so a Player can host a game and others able to join. Without the need of self hosting a server or manual Port Forwarding if thats possible 🙂

clear bridge
#

Hi, what does the NetworkAnimator component do in Unity Netcode? It synchronizes the entry animation of my characters, but when a clients starts walking (so the animation switches from idle to walking), the other clients can't see the new animation

vast solar
#

Hey, what solution would you guys suggest for making a multiplayer browser game?
I went with mirror but then realized that you can't host a server on webgl build lol
should i actually just implement dedicated server or is there a way to make it work another way
i read somewhere that you webgl can never host, is that really true?

royal lava
#

CAN ANYONE HELP ME FIND A WORKING CLASS THAT SENDS AND RECEIEVES DATA FROM A SERVER ON THE LOCAL HOST IN UNITY? (UDP)

mortal horizon
mortal horizon
#

unless you wanna pay, then use photon

runic rampart
#

So webgl builds could host and be clients

#

Using MLAPI - running a deep profile on our game, we see that 35% of the frame time is being spent in BinaryFormater.Serialize, I believe this is in NetStatSerializer.cs. How do we get this cost down? We don't have much being sent over the wire continuously so I didn't think we were serializing all that much.

cedar mesa
#

is there anyway to use socket.io to connect to clients in unity with localhost?

vast solar
#

what do you suggest

austere yacht
ocean cradle
#

This dosent even have to do with code my Unity broke as my mirror wasn’t working so I reinstalled all of it twice and now unity is having a heart attack with the Mirror code, not even mine

#

And it’s not even one issue it starts picking random lines of code in random scripts each time like it’s spin the wheel

runic rampart
#

I am unsure about how to go about this

#

the reason you need a relay server for webgl games is because web browsers inherently can't directly speak to other web browsers

#

this is what web rtc solves

vast solar
#

hmm i see

#

ok thank u

verbal lodge
runic rampart
verbal lodge
#

I'm not sure (besides running in release mode or uninstalling the tools package). I'll ask

verbal lodge
runic rampart
hardy citrus
#

If i want to connect to a created steam lobby, what method do i use?
I have this one now for joining a SteamID

m_Transport.ConnectToSteamID = "125454847874545";

Steam lobby id and steam user id is different

verbal lodge
#

lobby is a separate steamworks feature. What you'd do is:

  1. Use steamworks to connect everyone to a lobby
  2. Decide on a host player in that lobby and share that with the other players in the lobby
  3. Use the transport to have all players connect to that id.
hardy citrus
verbal lodge
#

You call ISteamMatchmaking.JoinLobby and after that you call ISteamMatchmaking.GetLobbyOwner to get the SteamID of the owner then you connect to that id.

mild warren
#

Please help, I want to spawn a gameobject in unity using the instantiator from the multiplayer engine photon, but it doesn't work.

hardy citrus
#

How do i send vector3 position with Netcode? I need to convert bytes?

ocean cradle
#

How do I use different GameObjects at the same time?

I’m using mirror to create a tf2 style game with some alternating weapons, the issue here is that once I place a script on the gun inside of the Player prefab, it dosent work

#

It does work on the actual player itself, but for the type of system I want to use it’s just not a method I can use

shadow spoke
#

You make a shimmy

clear bridge
#

should the NetworkAnimator component in Netcode automatically show the client's animation to the other clients?

shadow spoke
#

The player itself should have a weapon manager, while the child objects are hooked up

ocean cradle
shadow spoke
#

You’d have a script on the gun that acts like a remote, so when you fire, it calls the guns script to do visual effects, etc

#

Most FPS kits that do networking have this sort of setup

ocean cradle
shadow spoke
#

What?

#

Explain what you did

#

Here’s a break down

#

WeaponManager

  • knows the current weapon via reference
  • knows the current weapon stats, ammo, etc
  • listens for client input
  • when triggered, it sends a shoot command to the server and locally plays animations and visual effects

WeaponRemote

  • handles spawning of visual effects when triggered
  • handles sounds, animation, etc
ocean cradle
shadow spoke
#

Just have the weapon remote take care of that

#

Make some sort of attachments system that toggles the meshes on and off

#

Again, you honestly should plan for this before you start programming it, otherwise you may encounter the snowball effect

#

aka Feature Creep

#

Alternatively, start with the absolute basics

#

Then grow from there

ocean cradle
#

What’s the snowball effect?

shadow spoke
#

Feature Creep

#

You do one feature, but then you’re like what if… and before you know it you have 20 features instead of just one

ocean cradle
#

Oh ok, I understand that

#

One more issue that is vital to the game if that’s not a bother
So I need a way to make the menu and map in different scenes, let me explain.

I’m using the basic network manager as a placeholder. One thing I hate about it is that the map and connection scene(The one with the network manager HUD) is the same. The issue with this is that if I want to inevitably, and very soon, add more maps, it’s not gonna be possible

shadow spoke
#

Make the menu offline

#

For example, when you disconnect from my game, the game goes and cleans up stuff and takes you back to the menu.

#

Menu is offline

ocean cradle
#

Wait but how does that load you into a new scene/map?

shadow spoke
#

What do you mean?

#

When you connect to a mirror server it already loads the map the server is on

ocean cradle
#

If I have more than 1 map I would need a system in which the client loads into a new scene, aka the map. Because if it’s gonna have different specialists I think I would need a separate unity scene which the client loads into to choose his character, and then join the map

shadow spoke
#

If you are in a server and you call Mirror ServerChsngeScene then all clients are notified and they’ll change scene.

#

You’d find that a lot of the select operator stuff is actually an additive scene loaded into the current one

#

For example, the one off the top of my head that I know uses that is Genshin Impact

#

It actually loads an additive scene, turns off the world camera and related stuff, shows your characters, then when you leave that menu it resumes rendering the world

#

Alternatively, you can do what I do and send a custom Command to spawn your character as well as set them up with equipment etc

#

But that’s down the track

ocean cradle
#

So what you’re saying is that I should just load in maps as prefabs and do it all in one scene?

shadow spoke
#

Make the operator stuff as an additive scene and then toggle camera between world and operator select

#

Put the scene at like -1000

#

On the Y axis

ocean cradle
#

I’m a bit confused on what you mean by “operator stuff”

shadow spoke
#

Operator select or whatnot

#

Alternatively you could just have a UI menu

#

That has mugshots and you just get the user to pick the operator that way

#

There’s many ways of tackling this

ocean cradle
#

So- I make a separate scene for the main menu, it’s offline and is not the actual server, and once the client connects to the server the scene changes to the actual server, with a room where you can pick your character/specialist, once chosen you vote a map, if a previous map was already there, it deletes that one and spawns in the new map which are just huge prefabs?

shadow spoke
#

More or less… I could break it down further but I’m about to do a 40 minute drive so I’m outta time

ocean cradle
#

Alright, I think I understand it, thanks for the help

shadow spoke
#

I actually want to do a series of no bullshit topics like this, like how to spawn a object but with different things

#

Covering both Mirror and Mirage

#

Basically tidbits that can help others

#

Presented in a friendly and respectful manner

runic rampart
rocky garden
#

can we change scene in photon..??

#

i have 3 scenes setup main menu room 1 and room 2

#

i managed to spawn the player to room 1 from main menu

#

to enter room 2 ive put up on trigger

#

but room 2 doesnt seem to work properly with multiplayer game

#

need some help with this

ocean cradle
shadow spoke
#

Just gotta make sure my script is short and sweet but covers the dot points enough.

fresh folio
#

Does anyone feel that Netcode for GameObjects is production ready? I know it's new but other than the boss demo there's no other examples or studios that I know are using it,.

hardy citrus
#

I have a P2P networking solution, I need to update player position to other clients, but I dont want the my player to be affected by position change to server
Easiest solution to only update on other clients, not mine? My player is both server and client

sand pulsar
#

Hey guys, did anyone manage to run a Server Build with Steam transport over a Linux Distribution? I get so weird errors which relates to steamclient.so, which doesn't appear on Windows.

rocky garden
#

Need help photon unity to switch between scenes

sterile vortex
#

Hey, anyone have experience with photon fussion ?, specifically syncing animations with network mechanim. If you know a working example i can take it from there

rocky garden
#

hope i find any solution

sterile vortex
#

ill send a msg if i find a solution, hope u do the same ;D (currently it works on host only, client is not synced)

rocky garden
#

thank you so much

rocky garden
#

also @sterile vortex are u familiar with photon pun

sterile vortex
#

no, sry. ive only worked with fussion so far

rocky garden
#

ohh ok no problem im having problem with scene changing

humble heron
#

Hey all! I posted this over in the Mirror discord, but was curious if anyone here might have some input:

Good afternoon, fellow developers! I've been using Mirror to develop a simple platforming game over the past few months. Since the beginning of the new year, I've been stuck on the big problem of how do I handle physics in my networked game.

The core of my game has platforms that rise up and down. When attempting to get this to work out of the box with Mirror, due to the normal latency between server and client, and the natural desync of the platform positions as they move, the characters from the other clients will always float above platforms / rise through platforms. It seems that without implementing some form of Client Side Prediction + Lag Compensation + Server Reconciliation + etc... I can't achieve the desired results out of the box with Mirror.

So is everyone who has some physics related interactions in their game implementing some custom form of CSP? Or am I approaching this wrong / missing something. I know this is a industry wide problem that has no perfect solution. I'm just curious what everyone else's experience has been!

Through a lot of research I've found one example that applies CSP in Unity (by simulating a client / server setup) and one project that attempts to do so while also using Mirror.

It's been really frustrating because I've had to shift my entire focus into understanding CSP and all of its facets instead of being able to work on the actual gameplay. I would love to find and pay for a solution that has already been developed if possible.

Thanks so much for any feedback / advice (:

austere yacht
humble heron
austere yacht
#

maybe you can get away with a simple version of it

humble heron
#

I've been working on adapting a c# version I found into mirror (networking package I'm using), but its been a hell of a job. While I've been learning a lot, I really want to get back to developing the actual game lol...

austere yacht
#

its maybe a bit too much if your focus is on making a game rather than a networking library

#

a basic implementation should not be that much work but a great one definitely is

runic rampart
#

Using Netcode for GameObjects - I have a prefab A which has another prefab B as a child. Both of these prefabs are network objects. When I instantiate and spawn A, do I need to manually spawn B as well?

#

Looks like the answer is yes - I feel like potentially this could be pushed down into the Spawn call itself rather than me having to do it

orchid gate
#

I'm making a multiplayer game that is currently connecting everyone, but not showing movement updates. I've serialized the vector and passed it server side, but it's not showing updates, just original locations.
Currently using Mirror

hearty dock
austere yacht
runic rampart
austere yacht
#

it just seems weird conceptually

grave ice
#

is there a way to send data using netcode for game objects

#

i cant find the docs for it

polar lagoon
#

Is there a way to open ports in unity?

grave ice
#

use a relay network @polar lagoon

rocky garden
#

Hey anyone available

#

Need small code changes nothing big

#

Im working with photon

runic rampart
austere yacht
young jay
#

hi does anyone here knows on making multiplayer game through LAN or hotspot mobile

sand pulsar
#

Does anyone know a strategy to remove shaders from a server build?

high night
#

@sand pulsar I think thats what headless build is for

#

But it probably removes more than shaders

sand pulsar
pliant sundial
#

The dedicated server build is really bad, it only strips a little and you still need to do a lot of manual stripping or use something like the Headless Builder asset

sand pulsar
pliant sundial
# sand pulsar ah okay sad that dedicated server build has no chance to strip that away :/, but...
crystal pilot
#

Hello I'm using Photon what is the best way to sync the map seed over the network ? Should I use a CustomProperties or a RPC ?

crystal pilot
austere yacht
#

well, you can do basically whatever there, if you had syncvariables i'd use that

crystal pilot
austere yacht
#

their website has lots of documentation

#

is there a specific reason why you selected PUN?

#

(just curious)

mortal horizon
crystal pilot
austere yacht
crystal pilot
# austere yacht all except quantum have a free tier

I have a problem with the OnRoomPropertiesUpdate method. I use this to update a property:

public void StartGame()
    {
        System.Random rng = new System.Random();
        // Generate random int between 0 and 100000
        int seed = rng.Next(0, 100000); 
        customGameProperties["MapSeed"] = seed;            PhotonNetwork.CurrentRoom.SetCustomProperties(customGameProperties); 
    }

public override void OnRoomPropertiesUpdate (ExitGames.Client.Photon.Hashtable propertiesThatChanged)
    {
        base.OnRoomPropertiesUpdate(propertiesThatChanged);
        // MapSeed changed
        if (propertiesThatChanged.ContainsKey("MapSeed")) 
        {
            // Get the seed value
         int seed = (int)propertiesThatChanged["MapSeed"]; 
         Debug.Log("Game seed received: "+seed);
         // Generate the map
         map.GetComponent<Map>().Generate(seed); 
        }
    }

The problem is that OnRoomPropertiesUpdate is only triggered on the master client which set the custom property. Why ?

weak plinth
#

Hi

obtuse pumice
#

I'm building a turn based multiplayer game. The game timer is the only part which is real time and needs to be somewhat synced between clients.

What do you guys think about using an ASP.net core app for a turn based game? The client will have to make time sync requests a few times each
second which will be done over UDP, when the request is processed on the server it compare the client state with the server state and if the client
is behind it will include a flag in the time response (also sent over UDP).

When the client receive the UDP packet it will check the flag and if it's behind it will request the new state via a normal HTTP call.
When a client make a move in game it will just post it over http as well.

So basically everything is done over http besides the time/state check which is done over UDP.
Polling over UDP is very cheap and I also get the stability and multithreaded performance of ASP.net without having to manage any connections.

Is this totally crazy? would there be any downsides I have missed?

Sorry for the long post.

austere yacht
obtuse pumice
#

thank you for answering, yes I make sure that they execute in proper order and if some packets are dropped it's okey since the clients will continue to send packets every n (probably 250) ms

austere yacht
#

i'd not use ASP as a framework since its targeted at a wholly different use-case and locks you into MVC

obtuse pumice
#

I do agree that ASP feels a bit bloated but you can create pretty good rest apis in core without the whole MVC part

mortal horizon
#

you should just grab a reliable udp implementation off of github and use that instead (KCP, ENET, etc..)

mortal horizon
#

and do the server in net core

austere yacht
#

just get rid of that bloat

obtuse pumice
#

yeah I thought about that as well but than I have to make it multithreaded myself

austere yacht
#

you have to do that anyway

#

automatic multithreading only works when your app fits exactly into the frameworks mindset

mortal horizon
#

if youre just making a turn based game im not sure how much benefit multithreading will give you

#

other than a bunch of headaches

austere yacht
#

i dont think the ASP multithreading will help you in any way

obtuse pumice
#

ASP have async IO processing which is pretty nice

austere yacht
#

its completely built for scaling parallel and independent CRUD requests

obtuse pumice
#

yeah, I did not mention it in the post above but I kind of need to run lots of matches (1v1 games) in the same process

#

so lots of IO from different clients

obtuse pumice
austere yacht
#

sounds like you would want to definitely do the threading yourself

obtuse pumice
#

Maybe. If it's IO heavy I'm not sure I would be able to make something more efficient than ASP

austere yacht
#

there is no secret black magic that makes ASP amazing at everything... if you build a solution that exactly fits your problem it'll be 100X more efficient/performant

#

just by not doing all the extra stuff that ASP does, and by allowing a structure that is optimal for your situation

#

so if you want "lots" of players concurrently, custom is the only way

obtuse pumice
#

that's true, a more specialized solution should perform better. Guess I have to think a bit more about it and weigh in the time cost as well.
Thanks for the answers!

modest light
#

Excuse me, I want to ask a question, is it possible to make mmorpg by only linking to mysql?

bold wagon
#

Hello, guys i cant add multiplayer to my game with netcode everything is works but sometimes i have error Object refference not set to instance to an object line 58
code:

async void Start()
    {
        // Initialize unity services
        await UnityServices.InitializeAsync();

        // Setup events listeners
        SetupEvents();

        // Unity Login
        await SignInAnonymouslyAsync();

        // Subscribe to NetworkManager events
        NetworkManager.Singleton.OnClientConnectedCallback += ClientConnected;
    }

    #region Network events

    private void ClientConnected(ulong id)
    {
        // Player with id connected to our session

        Debug.Log("Connected player with id: " + id);

        UpdateState?.Invoke("Player found!");
        MatchFound?.Invoke();
    }

    #endregion
frosty crystal
#

Hello

#

Which Azure VM should I choose for development purposes

hardy citrus
#

Is it possible on someway to add 2 classes to a class,
Like: public class MyScript : NetworkBehaviour : AnotherClass

hardy citrus
austere yacht
# hardy citrus So if i have a class, with an enum, how do I solve it to add this to my scripts?

Via composition, i.e. some variation of creating a field and giving it a reference to an instance of that other class ```cs
public class MyScript : MonoBehaviour {
private OtherClassWithEnum enumClass;
private void Awake() {
enumClass = new OtherClassWithEnum();
}
}

the canonical way in unity is to add that second class as another component on the same gameobject
```cs
[RequireComponent(typeof(OtherClassWithEnum))]
public class MyScript : MonoBehaviour {
    private OtherClassWithEnum enumClass;
    private void Awake() {
      enumClass = GetComponent<OtherClassWithEnum>();
    }
}
hardy citrus
tired trail
#

Hey, I'm making my game quite modular in the sense that every enemy, projectile, wave etc is accessible and modifiable in XML form. The problem I'm currently encountering is I'm not sure how I can send all this deserialized XML data to a client when they connect. Any suggestions? ( using the new Unity Netcode for gameobjects)

austere yacht
# tired trail Hey, I'm making my game quite modular in the sense that every enemy, projectile,...

depending on your game design they should already have it by having the build of your client, or get it by downloading a patch from some sort of web api or you send it in little chunks as needed over the netcode messaging system. generally this sort of thing should not even be required information on a client of your game provided it is a regular, server authoritative system where the simulation is handled entirely by the server. If its there for ui purposes, the web api things is probably most straight forward. You can make that part of your server, run a little HttpListener next to the regular netcode.

tired trail
# austere yacht depending on your game design they should already have it by having the build of...

Yeah so, the client simulates everything themselves but the server tells the client where x will spawn and handles damage registration etc.
Currently the idea is that the server/host can just modify the XML in their directory to customise all the player weapons, the enemies that will spawn etc. The way I was thinking about obtaining that data on the client was to just download the server's XML configuration into a temp folder and then load it as normal.

sweet slate
# bold wagon Hello, guys i cant add multiplayer to my game with netcode everything is works b...

Kinda late answer, but, just a wild guess
If the error is at one of the lines (idk which one is line 58) where you're doing ?.Something(), you could try using a proper null check instead.
I recently had an issue where ?. didn't work while != null did, and my IDE told me that i shouldn't use ?. for Unity Types, never had that issue before, never got that message before, but it did work afterwards 🤷‍♂️

austere yacht
sweet slate
#

Oh, thx for the explanation! Now I don't only know that it's an 'issue', but also the reason behind it!
Personally, i don't like the if(someUnityObject){} and instead prefer if(someUnityObject != null){}, but very good to know the tech behind that stuff. I was kinda surprised when ?. didn't work, but your explanation makes totally sense, tyvm!

austere yacht
#

you can also do if (!this) {} to check if an object is currently being destroyed. Can help with avoiding those pesky exceptions when exiting playmode/unloading

solemn haven
#

I am updating these photos from image uris but when I join with another account (photon) photos are not changed

#

how can I fix that?

glass steeple
#

change it

solemn haven
#

I found some way using this but

#

idk what it wants

scarlet hull
#

i need help, my loading scene doesn't work to load the connected player to the lobby scene:

#

(my Lobby is named Lobby for anyone thinking it's because of that)

austere yacht
scarlet hull
#

It seems as if my connection to the server does not work, did i configure something wrong?
it does not seem to be able to connect to the master server

median mason
#

Hi, what would be a good way to implement cross platform multiplayer in my chess game?

hexed sierra
#

Hello, I need some help about the Netcode Unity system, for the Networkvariable if anybody got some time ? (i'm a beginner in c# & unity)

#

I'm stuck since a while now and i don't find my answer, however, I think this is a basic thing I don't get yet because i'm French and sometime it's hard to properly understand tutorials/explanations

orchid gate
#

I need some help. I've prepared a player for a network game. It has been made into a prefab for players to spawn as they connect to the server. but each one isn't spawning with it's camera seen in the first attached photo. This is during runtime. The photo after that is of the prefab as it should spawn in. All I see is the Main camera view in the last photo. Any insight is greatly appreciated!

orchid gate
#

yes

austere yacht
#

you cant do that, each net object has to be spawned on its own, there is also little point in making it a netobject since it already is part of one

orchid gate
#

Wow thanks! that got it semi working, now i just need to adjust my offset! thank you so much

austere yacht
#

yw

clear bridge
#

Hi, should I create a camera for each player?

austere yacht
clear bridge
#

because I thought I was doing something wrong: the camera works well, but i get this error

#

this is the camera script

#

and this is how I set the target

austere yacht
#

thats usually all you need, hook up camera with the local player object... unless you have special needs

bright mauve
#

(my camera starts disabled and than I enable it when my player joins the game.
this is to avoid other player's cameras over-riding this one.)

#

not sure why this is happening

orchid gate
#

My camera is being overwritten and applied to each new player than joins. So if player 2 joins player 1's cam goes to player 2 if player 3 joins player 1 and 2's cam's jump to 3's

bright mauve
#

great fix to this, Thank you!!!

bright mauve
#

lol

orchid gate
bright mauve
#

originally? normal cams for each player and they all start disabled

orchid gate
#

yea i'm trying to solve the problem of overriding now

bright mauve
#

I enabled each one on their own (if clientid == localid) camera

orchid gate
#

okay

bright mauve
#

so this was my fix

fluid tapir
#

Hi, so I'm looking for a multiplayer solution for a 4 player Coop game. What are your thoughts on PhotonNetwork? Thanks!

bright mauve
#

probably the most developed and supported right now.

netcode for gameobjects is good but only the myth luke is a top expert at this for now (who is active at discords)

fluid tapir
#

Hmm, I know PhotonNetwork gives a free server which you can use. Do you happen to know if netcode provides servers or is it P2P?

bright mauve
#

p2p

#

thats not how it works

#

you are the one making the server / client through it

#

I mean, you get the option to choose.

shadow spoke
#

if you were expecting "free server" as in "free dedicated server instance", then no.

sage valve
#

Using photon:

    public override void OnPlayerLeftRoom(Player otherPlayer)
    {
        Debug.Log(otherPlayer.NickName + " left the room");
    }

when other players [x] leaves the server, how can i make this log show up for others?
this doesnt seem to work.

#

on [x]ing out of the game, all the gameobjects gets cleaned up, so the game knows someone left.
i just dont know what its calling to get that information

somber drum
#

server => clients a message

sage valve
#

its not firing at all, no matter who leaves

#

roomOptions.CleanupCacheOnLeave = true;
is cleaning up the game
i just wonder if i can access the "onleave" part

somber drum
#

mm just guessing, if you have the right namespace and derived from MonoBehaviourPunCallbacks OnDisconnected(DisconnectCause cause) might be worth a shot.. if not I would ask in the official photon discord in case nobody gets to you here @sage valve

sage valve
#

ondisconnect works fine, its just unexpected quits that crashes the game

somber drum
#

I'm not sure what all goes into preparing for an unexpected quit in pun, though I'd imagine there would be some cleanup to do like objects belonging to said player being reset to some other owner

#

ofc I don't think they handle host migration out of the box so if it's the host quitting that makes sense.

#
  • shouldn't be a crash though
sage valve
#

it crashes because i have the player object stored in an array
the reason i want to check for "OnQuit" is because i need to clear that array

clear bridge
#

Hi I'm using Netcode and I'm trying to stream every player's animation to the other player... is there a way to do it fast? I could create many NetworkVariables but I don't know if a better way exists

remote mulch
#

before one client would control both players

#

so i added ```void FixedUpdate()
{
// Update IsRunning from input.
IsRunning = canRun && Input.GetKey(runningKey);
if (view.IsMine)
{
// Get targetMovingSpeed.
float targetMovingSpeed = IsRunning ? runSpeed : speed;
if (speedOverrides.Count > 0)
{
targetMovingSpeed = speedOverridesspeedOverrides.Count - 1;
}

        // Get targetVelocity from input.
        Vector2 targetVelocity = new Vector2(Input.GetAxis("Horizontal") * targetMovingSpeed, Input.GetAxis("Vertical") * targetMovingSpeed);

        // Apply movement.
        rigidbody.velocity = transform.rotation * new Vector3(targetVelocity.x, rigidbody.velocity.y, targetVelocity.y);
    }
}

}``` the View.isMine so i only control mine,but it controls the other client

remote barn
#

try localplayer

remote mulch
remote barn
#

insted of ismine

#

is.LocalPlayer

remote mulch
#

kk

remote barn
#

or is.Client

#

are you using uNet?

remote mulch
#

never heard of so i would say no,im using Photon if u mean by system for multiplayer

remote barn
#

gime a sec

remote mulch
#

k

remote barn
remote mulch
#

and im guessing errors cuz i need to add Unet

remote barn
#

no

#

Unet and photon are different things

remote mulch
remote barn
#

Have you refer the photon library?

#

using Photon.Realtime;

remote mulch
#

im using Photon.Pun so u can type a password for creating a room and when joining u type tht password

remote barn
#

I know whats photon

remote mulch
#

:)

remote barn
#

But what do you want to make

#

a script to move players

#

or what?

remote mulch
#

idk i just want to fix the fact tht one client is moving the other

remote barn
#

ok

#

gime a second to check one of mine pryects

remote mulch
#
using UnityEngine;
using Photon.Pun;

public class FirstPersonMovement : MonoBehaviour
{
    public float speed = 5;

    [Header("Running")]
    public bool canRun = true;
    public bool IsRunning { get; private set; }
    public float runSpeed = 9;
    public KeyCode runningKey = KeyCode.LeftShift;
    PhotonView view;

    Rigidbody rigidbody;
    /// <summary> Functions to override movement speed. Will use the last added override. </summary>
    public List<System.Func<float>> speedOverrides = new List<System.Func<float>>();



    void Awake()
    {
        // Get the rigidbody on this.
        rigidbody = GetComponent<Rigidbody>();
        view = GetComponent<PhotonView>();
    }

    void FixedUpdate()
    {
        // Update IsRunning from input.
        IsRunning = canRun && Input.GetKey(runningKey);
        if (view.IsMine)
        {
            // Get targetMovingSpeed.
            float targetMovingSpeed = IsRunning ? runSpeed : speed;
            if (speedOverrides.Count > 0)
            {
                targetMovingSpeed = speedOverrides[speedOverrides.Count - 1]();
            }

            // Get targetVelocity from input.
            Vector2 targetVelocity = new Vector2(Input.GetAxis("Horizontal") * targetMovingSpeed, Input.GetAxis("Vertical") * targetMovingSpeed);

            // Apply movement.
            rigidbody.velocity = transform.rotation * new Vector3(targetVelocity.x, rigidbody.velocity.y, targetVelocity.y);
        }
    }


}```
#

this is my player movment script

#

and in thr

#

i put the view.IsMine thingy so i can only control my player instead of both

#

at once

#

but now i need to figure out

#

why this is happening

remote barn
#

gime a sec

#

bc view.IsMine isnt for that

#

you have to if (This.LocalPlayer =! null)

remote mulch
#

well i showed u the error it gave me

remote mulch
remote barn
#

heres how i made it

#

it works whit photon

remote mulch
#

hippidy hoppity ur code for slopes is now my property

remote barn
#

you need to add this componets to the player

remote mulch
#

yup

#

oh wait

#

transform view

remote barn
#

is to other clients see yours

remote mulch
#

wot?

remote barn
#

it works?

remote mulch
#

ill test

#

hol up let me open a second game

#

oh yea

#

wht about this tho

remote barn
#

using my script?

remote mulch
#

oh let me try

remote barn
#

make sure to copy it all in discord inst show the last 47 lines

remote mulch
#

ik ik

remote barn
#

umm

#

I dont know about networking whit photon srryy

remote mulch
#

lool

remote barn
#

y tried srry i have to go

remote mulch
#

anyone else?

last ocean
#

how would you compare photon to Mirror? i know photon is a beast of a system to use but it can be rather expensive but also probably faster to setup than Mirror. I havent touched networking stuff in like a year or 2 been very busy but im trying to get back into actual game dev and have to decide between thhe 2 again

#

essentially im trying to have some light server auth for when players try to deal damage or collect loot to avoid hackers etc

fluid tapir
#

Is there host migration for unity netcode?

austere yacht
clear bridge
#

Hi, do you know any way to stream an int array using Netcode?

austere yacht
clear bridge
#

Thank you, I need this to send to server client's animation params, do you think this is a good way to do it? I tried using NetworkAnimator but I can't make it work... Or maybe I didn't understand how it works

austere yacht
#

but i’d only use that rather elaborate method when there is a need to be maximally efficient about the data bandwidth

lofty kite
#

hello. I am alyx from beanie co. we are looking for someone who can help us make the game multiplayer. as well as make a in browser lobby that can allow people to join player made games. and make a custom player. if you are wanting to help, please DM me. you will be given a custom worker only skin. thank you -alyx(creator of beanies)

ocean cradle
#

This dosen’t have to do with code, more about mirror and setup.The player instantiates a bullet once the mouse button is pressed, and then it does show up, but only on the local client and not any other client who has not fired the bullet

#

To add to this: the bullet has it’s own network transform and network identity

weak plinth
#

im making a multiplayer 2d survival/sandbox game that uses terrain generation, and i have a script for creating and joining rooms, which is seperate from the script that generates the terrain. in the create and join rooms script, there is a create room function that generates a random seed and the terrain generation script uses that generated seed to generate the world. this works fine, but the problem is when someone joins the room, the seed defaults to 0. im not sure what the problem is, maybe its because i give a value for seed only in the create room function? if i try doing it in start then the player joining also generates a new seed. can someone help me?

boreal zodiac
#

saw an update to Mirror. Made the mistake of removing my copy, installing the plugin update. now OnStopLocalPlayer is gone

granite yew
#

Ok so im making a multiplayer game and i have a lobby system where the host can change scene from lobby to game and each player can pick a skin in the lobby, how can i put the variable of the skin i chose in the lobby and carry over to the game scene?

alpine rock
#

Wondering if anybody can help me. So i am using Mirror for networking, and I have put my player Prefab into the network manager game object.

I have my Player prefab setup with NetworkIdentity and Network Transform (Script) from the mirror package. I also have a "Player Controller" script which moves my 2d object using transform.position and transform.rotate. I set these using a [Server] tagged function which is called from a [Command] tagged function which is called by my update method.

When i connect with my first client (this host + client) I am able to move my player around, but when i connect with my second client (just client) I get "Does not have authority" . Why would my second client not have authority over their game object instantiated by the network manager?

ocean cradle
alpine rock
#

Hmm the problem is more sending the transform to the server tho

#

I have the network transformer setup and when i try to change position or rotation thats when i get the error

#

Everything works if i dont try to change transform with a server tagged method through. I thought i was suppose to change the transform in a server tagged function

weak plinth
#

im trying to make it so that only the owner of the room can create the seed, but when i use this code the person joining the room also makes a seed. can anyone help?


public static ExitGames.Client.Photon.Hashtable addSeed = new ExitGames.Client.Photon.Hashtable();

public override void OnJoinedRoom()
    {
        PhotonNetwork.LoadLevel("Game");
        if(PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.CurrentRoom.SetCustomProperties(addSeed);
        }
    }

private void Awake()
    {
        Instance = this;
        addSeed.Add("seed", Random.Range(10000, -10000));
        seedInputField.text = addSeed["seed"].ToString();
    }
#

hi

#

how can i make a steam multiplayer game

#

without entering tax info

olive vessel
#

I imagine if you want to release on Steam, you will need to give them your tax information

unreal otter
#

does anyone know how to make all the players in the network use the same camera? when the first person makes a lobby and plays it theres a camera that has animation and when the second person joins i want that player to use the same cam and if the animation is part way through want it to show on all screens

alpine rock
keen steeple
#

With Photon, how would I add score to a player on collision? Does Photon have a scoring system?

stiff ridge
bright mauve
#

just so i know i got networking correctly:
every player has the game running on his computer and its a different world for each player (a new client gets the game state from the server) and in run time the world does not automatically update. right?
if i disable an object for one or instantiate on a client, it will only be for a client, and when i move one i need to update the position myself? (or use network position)

polar meadow
#

Hi

#

I want the instantiated value to get followed by the camera how can I do it

edgy rain
#

Hi guys, im facing a problem with Photon Networking, can some one help me out? I need to destroy a scene object that is owned by the master client, apparently i couln't find a solution yet.

austere yacht
ocean cradle
#

To make what I said simpler, I am using Mirror, and I have a button that instantiates an Object, the Object, however, is only showing up on the local player and it dosent change even when I put a network transform on it

edgy rain
austere yacht
edgy rain
# austere yacht Have the master destroy it?

yes the master can destroy it, when the master hits the enemy then the enemy's health syncing and the enemy dies after its health its 0, if the client hits the enemy, de enemies health is going down but only locally i guess as its not displaying on the master client

edgy rain
edgy rain
austere yacht
edgy rain
austere yacht
#

the same way you do any other communication in your game

edgy rain
weak plinth
#

can i get help with PUN 2 here? (the networking api)

haughty heart
#

You can ask your question here, yes.

weak plinth
#

this is my code, the player in my game rotates around the mouse and when i try to do it on multiplayer it snaps to one cursor i tried is.mine with no sucess

ocean cradle
weak plinth
#

im using monob

#

i will also try islocalplayer

#

oh wait im suposed to use networkb

#

sorry im a bit clumsy today

#

when i go network behaviour the whole code goes red

#

the update method doesnt

#

only start

edgy rain
#

Can some one please help me with Pun 2??

full girder
#

What are some of the best Unity networking solutions? I know of Mirror, and Photon, but I don't know of any other ones

austere yacht
full girder
mortal horizon
#

it's new and api will most likely change

austere yacht
#

it requires you to know what you are doing

mortal horizon
#

that too

full girder
#

I see

austere yacht
#

its in preview, so may change, but is largely done, the last big change was from pre-release to 1.0

mortal horizon
#

imo, mirror if you have no money and not alot of experience, photon if you are ready to spend money, if youre just making stuff to learn then maybe try making something from scratch using a reliable udp library

#

it really depends on what you are making

austere yacht
#

Photon PUN/Fusion/Quantum are also very opinionated

full girder
mortal horizon
#

i would say photon fusion then

#

its the best to make an fps atm

#

if you have money tho

#

i think they have a free tier too tho

#

it's quantum that doesnt

mortal horizon
full girder
mortal horizon
#

opinionated :D

full girder
#

oh 🤦‍♂️

mortal horizon
#

🤣

austere yacht
# full girder wdym?

Photon Fusion is perfect for up 64 players in a FPS/ARPG type game, and aimed squarely at the needs of that, if you want to deviate from what Fusion thinks is the best way to do something, it looses all its niceness

mortal horizon
#

if youre making something like valorant or csgo, fusion all the way, you cant get any better than that, the guys at photon have some pretty cutting edge stuff backing their new libraries

austere yacht
#

In something like Netcode, nothing is nice unless you make it so, but you have all the power to create the world to your liking

full girder
austere yacht
#

fusion is server authoritative, efficient, modern, fully featured, has client side prediction with eventual consistency, supports rollback, supports a dedicated server PUN is old, less efficient and simple with few (if any) advanced features. Both build on Realtime & Photon Server, so in theory you can add whatever is missing yourself.

full girder
#

interesting

#

I will try out fusion if there is a free version

#

is there a good tutorial series for fusion btw?

austere yacht
full girder
#

alright thanks

austere yacht
#

mind that you will not be making much of a multiplayer game if you have to rely on tutorials, reading docs, some theory, trying things and testing is what its all about

full girder
austere yacht
#

there is very little structured learning content available for game networking topics

full girder
#

alright

quiet ginkgo
ocean cradle
#

Hello does anyone use mirror here and can help me?

gray walrus
#

I have a project with firebase real time database but when i test it i get this error, can someone help me please?

#

Here are my codes

using System.Collections.Generic;
using UnityEngine;
using Firebase;
using Firebase.Database;
using static Firebase.Extensions.TaskExtension;

public class DatabaseManager : MonoBehaviour
{
    private string json;
    private DatabaseReference dbReference;

    void Start()
    {
   dbReference = FirebaseDatabase.DefaultInstance.RootReference;

UserScript newUser = new UserScript("Test","15");
json = JsonUtility.ToJson(newUser);

dbReference.Child("Farms").SetRawJsonValueAsync(json);


    }
}```

public class UserScript
{

public string name;
public string age;

public UserScript(string name, string age)
{
    this.name = name;
    this.age = age;
}

}

alpine rock
#

In my network manager, i have a List of players. But when a player connects, their client doesn't seem to know about the list of players. It's just empty. Any ideas?
OnServerAddPlayer and OnServerDisconnect of my network manager adds and removes players from the list
Basically when i call List<ArenaPlayer> players = ((Connection)NetworkManager.singleton).players; on the client instances it's empty, where as on the hostclient it has all my players

austere yacht
broken ledge
#

Folks, any smart tips on how I can keep track of concurrent players on all my servers?

trail parrot
#

Hi all
We're looking into using quantum mainly for the uncheatable/economics relation, but i need help in deciding if it's worth the price, and what monetization style makes sense. Anyone got insight on games made with quantum vs their money strat?

#

If 1 ccu is 0.5$, 1 DAU can pay off that per day, assuming the type of game is not a long running one for every player, but session based/casual

#

I'm probably talking nonsense, someone please suggest a better way to break this down?

nocturne pollen
#

Hello
I am currently doing a fps multiplayer with Photon 2, is Unet easier to use or harder than photon?

stiff ridge
#

PUN 2 is hard to beat in terms of "simple to use". We'd pitch Fusion for shooters, as it gets you much better results with only slightly more complexity...
Unet is properly outdated. If you wanted to, use Mirror, Unity Multiplayer Networking or any other solution. Checking out a few may make sense for you.

nocturne pollen
edgy rain
#

Hey guys, can some one tell me how can I sync the Enemy's(scene object) health to the other player, if im the master client all works fine but when the client cause damage then its not displaying for master client however the health of the enemy reducing. some one?

spare tapir
#

Here is my server code

#

and client code

#

I do make sure that the ipaddress and port are the same

#

But the problem is the server never receive the connect of the client

#

The client script doesnt debug an error,so I think client's connected

#

Plz help! > <

dry iron
#

hello guys how are you doing, I hope you are doing well. So I wanted to ask about something, I was following a tutorial about making character's profile which has his name, Exp, Level and his money. He also made the character's profile to be saved depending on the binary formatter which I don't like because then the players would be able to change their profile easily and gain money, exp and level ups. So what to do in that case or how to deal with it? do I continue using the binary formatter or what exactly! and thanks 🤗

feral oak
#

I’m using Photon to make a co-op game and I need to instantiate the player in the game, but each person can be wearing different gear. How should I go about ensuring the player is instantiate with the specified gear. Just looking to be pointed in the right direction, having trouble wrapping my head around it, multiplayer wise.

feral oak
mortal horizon
feral oak
#

Anyone that can help with the above issue? Or maybe needs me to further elaborate?

patent fog
#

Assuming your player is logged in beforehand, and that your prefab holds all the available gear objects in place but disabled, it's then just a matter of reading current equipped gear data and activate the right gameobject(s) when spawning, right ?

#

So as always, the answer is: implementation depends a lot from game to game

feral oak
#

@patent fog that’s how I had planned to do it so I’m glad you brought that up. My thought though, is there a more efficient way? If I have say 10 helmets, 10 body armors, and 10 guns and I want the game to know which one each player selected. Is it more efficient just to say make a modular character like we think or is there another way that I’m not thinking of.

#

Just trying to think of the most efficient way to code it so it’s not a lot of repeated ugly code activating and deactivating objects

#

If you need a game to compare the style of character customization I’m talking about, it would be something like an RPG or a Shooter where you can customize your character with items you own outside of the actual match and then spawn in with those specified items

patent fog
#

yeah I was thinking smthg like Fall Guys

#

There shouldnt be "a lot of repeated ugly code" though, shouldnt be afraid about that

#

and never forget, you never try to optimize early, only when performance hit occurs (and is demonstrated via profiling/monitoring)

feral oak
#

Sounds good, I’ll give that a shot. Appreciate your help.

next fog
#

Anyone here could help about how to calculate server & database needs for asynchronous multiplayer?
(If this question is not related to this channel, let me know.)

bright mauve
#

Does anyone know if there is a way to check when all players have finished spawning?

#

or a way to get a list of all spawned Players?

#

(that networkManager Spawns on netcode)

austere yacht
# bright mauve Does anyone know if there is a way to check when all players have finished spawn...

If it doesn’t exist yet you can make one yourself since the server pretty much knows everything about spawning players. For knowing when a player is ready, either use a serverrpc (if the specific ready signal you need isn’t built in) or use the builtin ones (Scene events/Pending connections), or both. The NetworkManager has a list of all pending and connected clients and their player prefabs

silk iron
#

Hello, I need some help: The custom property (bool)"dead" don't changes when I eat a player, but I get the Debug.Log("You ate a player"). So the bool dead is always false and never changes.

PUN 2

wraith marsh
#

If I want two simultaneous scenes on the server at the same time (clients in different scene) do I just load level additive and offset it from the other scene on the server? Or is there a cleaner solution to run multiple on the server like separate worlds with own origin origin?

austere yacht
wraith marsh
#

So you just shift them around the world so they aren't near each other then? Ok, thanks.

austere yacht
#

it would probably be easiest if all scenes have their objects placed such that they do not overlap

wraith marsh
#

Are you saying when I make, say scene X , I should have that scene offset from the world origin inside the scene itself so when it's loaded additively it's offset already?

austere yacht
#

mind floating point accuracy when doing this though... usually at 8k+ units from the origin glitches start to show up

wraith marsh
#

yeah I'm kind of worried about that but my levels are going to be small, I think it'll be okay

austere yacht
#

naturally, you can also stack vertically (if that helps)

wraith marsh
#

yeah that'd be taken advantage of

#

I guess I'll mess around with, thank you.

bright mauve
austere yacht
bright mauve
bright mauve
#

@austere yacht Do you know how can I Spawn the playerObject?

#

when I startHost(); It starts without spwaning the player (like i want) but than i want to tell the networkManager to spawn all players.

austere yacht
bright mauve
#

i see.

#

so i will first instantiate the player and than look for a function to connect it to the server

austere yacht
#

no

bright mauve
#

i mean after the client is connected

austere yacht
#

you can use the built-in autospawn and just disable the part of the object that you want invisible, or you have the server spawn additional objects for each player when they join/start a game and hook them up via network events

bright mauve
#

I looked up everywhere but can't find anything about the auto spawn

#

how can i access it?

austere yacht
bright mauve
#

but lets say i have a lobby scene and a game scene.
when my player joins the lobby i don't want this to auto spawn

#

when the player enters the game scene i want it to auto spawn. is that possible?

austere yacht
#

you might be confusing a few things here

#

that player prefab does not necessarily represent anything visual or interactive in the game

#

it is just a proxy object through which you can communicate with that particular client and connect it to other gameobjects/monobehaviours

#

what you do with that, what it means for your game, is totally up to you

bright mauve
#

then i am very confused, how do i spawn a player in the world?

austere yacht
#

by spawning a prefab just like any other

bright mauve
#

i have a gameObject player that has his camera, inputManager and all that stuff

bright mauve
austere yacht
#

you dont spawn a camera and input manager with the player prefab

#

those are unique to the client application

#

and should not exist for each player in the game

#

only for the local one

bright mauve
#

exactly.

austere yacht
#

naturally you can spawn those with the player prefab and just disable them for non-local players... but thats also extra stuff that isn't used

bright mauve
#

i have been looking for ways to solve this problem with the input and camera for days.
the only solution i found was by disabling and enabling.

i wrote a script that tells the player to enable its own camera.

austere yacht
#

so when a player object spawns, have it hook up to whatever you need it to communicate with in the local instance of the game

#

what people usually do is write an extension to the network manager that handles this kind of setup

bright mauve
#

wait, if i enable something on clientSide (GameObject.setActive(true)) will it also enable it for the other players?

austere yacht
#

but its very project specific

austere yacht
bright mauve
#

I see.

austere yacht
#

by default, only the server can change things

#

but you can pretty much do whatever you want, sync-wise, just have to follow the rules

bright mauve
#

so wait, can a client instantiate its own player?

austere yacht
#

you can have all clients do their own thing and maybe just sync a single value... or have all objects sync everything

austere yacht
bright mauve
#

ok so just so i know i understand:
everyone runs their own game, and the networkManager only does what i tell it to sync through networkObjects and NetworkComponents?

austere yacht
#

yes

bright mauve
#

i see.

#

so when i spawn a new player, best way to do it is just for every client that joins:

instantiate(player, position, rotation)
[clientrpc] -> EnableOwnCameraAndInput()
?

austere yacht
#

network objects and components are an abstraction over plain messages sent between client & server that make it easier to model your game in a way you are familiar with

austere yacht
bright mauve
#

what do you mean "the server to control that"

#

each client will control its own player if i do that. -> both players have network objects so they should sync?

austere yacht
#

normally you do something like this on the player object ```cs
public override void OnNetworkSpawn()
{
if (IsLocalPlayer)
InitCameraForLocalPlayer();

// ...

}

bright mauve
#

OnNetworkSpawn exists????

#

all this time?

austere yacht
#

sure

bright mauve
#

where is it written?

austere yacht
bright mauve
#

are we talking about netcode for gameobjects?

austere yacht
#

yes

bright mauve
#

networkManager.singleton.OnNetworkSpawn?

#

I Can't Find thisUnityChanDown

austere yacht
bright mauve
#

ohhh networkBehavior

#

found it. this is the true solution i was looking for.

#

Thank you so much!!!!! @austere yacht

austere yacht
#

😄

bright mauve
#

you are such a king

bright mauve
#

@austere yacht i tried instantiating a networkObject and it only instantiated it for the local computer. it is connected to the server but only placed locally.
even after networkObject.Spawn() it did not do anything.
am i missing something?

austere yacht
#

you have to spawn it on the server

bright mauve
#

What? but than how do i link each GameObject to its controller?

#

i mean to its user

#

or just for (Every userId)
{ instantiate(object) + Networkmanager.Spawn(object)}

austere yacht
# bright mauve What? but than how do i link each GameObject to its controller?

there are plenty of ways in unity that allow you to find the required components (.Find(), Singleton, static variables etc.). A player prefab is just like any other prefab that configures itself... if you don't like that approach you can hook into the NetworkManager.OnClientConnectedCallback from a component that is not spawned dynamically and carries the static references to the camera and other systems you may want to pass on to the local player object

ocean cradle
#

Can anyone help with Mirror?

olive vessel
#

You should just ask your question

ocean cradle
#

Yeah but nobody usually answers so I’m asking now to see if people ARE online so I don’t have to write a long paragraph every time

#

Okay, the issue is that I’m instantiating a projectile in my game, but it only shows up for the player who shot it. Now I registered the gameobject and used spawn instead of instantiate but it still didn’t work

#

This is becoming a very large issue and has been stopping all progress

#

I can’t just not take care of it at it is a main and very important to making the actual game

weak plinth
#

Hi

#

I get some errors

#

Failed to register task with System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> Firebase.FirebaseException: An internal error has occurred. --- End of inner exception stack trace --- --- End of inner exception stack trace --- ---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> Firebase.FirebaseException: An internal error has occurred. --- End of inner exception stack trace --- ---> (Inner Exception #0) Firebase.FirebaseException: An internal error has occurred.<--- <---

#

does anyone know how can I fix this?

jade hinge
#

i used face punch and built the rest

austere yacht
weak plinth
#

I need some Photon Pun 2 advice. So I am using Edy's Car Physics and I am setting it up to work with pun. To try and avoid having to go through all the scripts and add the IsMine check on everywhere input is added which would take awhile, I am just grabbing all the player objects before the player connecting is instantiated, and im disabling all the scripts for control, damage, etc and the camera on any player that is not the player connecting, so when they connect they just see the other players positions but because all the scripts are disabled they would only be controlling themselves. However, this does not seem to be working, from what I can tell even with the scripts disabled on the other user, the two users are still controlling eachother. Does anyone have any other ideas?

#

Also when player 2 spawns in, player 1's location changes to the same location as player 2 and they both go flying lol.

#

Which has me confused a bit but im assuming it has to do with the scripts. I know the flying away from eachother is from rigidbodies and im gonna disable the other cars rigidbodies as well. But idk why 1's position changes to 2's position when 2 spawns in

weak plinth
#

Looks like its time to just go the manual route and add the check in the scripts lmao

sage valve
#

for photon:
i need the masterclient to send rpc with target: newPlayer[i]
so to visualize: photonView.RPC("NewPlayerData", RpcTarget.newPlayer[i] , string newData)
this doesnt work.

shadow spoke
spring crane
sage valve
#

newPlayer[i] on its own didnt work either

#

because it was a gameobject not a target

spring crane
sage valve
#

getcomponent photonview then what?

#

.target

#

?

weak plinth
#

I am having this issue with PUN 2 where if player 1 is already in room in game, and then player 2 joins the room, player 1 seems to be re-instantiated at the same time player 2 is.

#

so basically anytime a new client joins the room anyone in the room already shoots back to their spawns

spring crane
#

How are you spawning things? Odds are it's something you wrote

#

Some of the car scripts could be reacting oddly or doing some kind of initialization that both clients react to

#

Perhaps change your player objects to be simple cubes to rule things out

weak plinth
#

I think its because im calling LoadLevel when OnJoinedRoom() is being called

#

so anytime someone joins, PhotonNetwork.LoadLevel(1) is being called and its reloading the scene for everyone maybe?

#

im testing to see if thats maybe it rn

spring crane
#

Yea that seems to be the likely culprit

weak plinth
#

hmm so then what would be the appropriate way to call LoadLevel

#

I basically want users to be able to create a room

#

and just be in it

#

and people can join

#

without it like reloading everyone everytime someone joins haha

spring crane
#

The current scene can be automatically synced through PUN, so PUN would make sure that the level is loaded

#

Only the masterclient should have to call that

weak plinth
#

Yeah I just tested it and I have that part right

#
    {
       
        if (PhotonNetwork.IsMasterClient)
        {
            PhotonNetwork.LoadLevel(1);
        }
    }```
#

not running on every join

#

so thats not issue

#

I think I may have fixed it tho

#

my unity is frozen tho KEKW

#

lol yeah I need to pay more attention to when things are running I didnt think about the fact my gamemanager does not run on every player spawn

#

I needed to add some stuff onto a script on the player object itself

#

I am a little rusty lol its been like 2 years since ive used unity and c# lol

snow mango
#

what

#

It clearly has a ServerRpc suffix

austere yacht
snow mango
austere yacht
#

Is this the only error you get?

snow mango
#

yes

#

it's also the only script I have

#

Using Unity 2021.2.13

austere yacht
#

Maybe reimport the script (via context menu)

drowsy parcel
#

Hmm.. should I install com.unity.entities (cuz i think you an enable full stack traces on there

#

)

feral oak
#

Haven’t done much with these since I’ve used Photon, so I’m gonna try my best to help

feral oak
weak plinth
#

Man it is so hard setting up PUN with Edys Car Physics

#

Shit does not want to work lol

#

Players still controlling eachother even tho I added the IsMine check everywhere I could

#

I shoulda bought a car controller with pun 2 support already added lol

#

I’d buy another one but then this would be the second one I wasted money on so gonna try and get it working lol

#

Does anyone have any tips for getting it working? First I tried just disabling all scripts on other players when a player loads in, to try and avoid having to go through and edit all the scripts with ismine but that didn’t work, then I went through and edited the scripts with ismine and it still doesn’t work lol

#

I tried reaching out to the dev of edy's car physics to see if they had any tips but no response and all their websites are down, wish I saw that before purchasing.

weak plinth
#

Hoping someone here maybe knows some trick I can do to get it working, I was hoping disabling the scripts on other players would work lol

snow mango
#

Using Netcode:
I find that the speed of the client is lower than the speed of the host. I'm using FixedUpdate with Time.fixedDeltaTime

opal tundra
#

Hi, do you have an idea on how to test a steam P2P based game on one computer or I have to at least have 2 to separate Steam account ?

austere yacht
opal tundra
#

Hmm

#

I was more thinking about having 2 steam accounts on the same computer but thanks for the repo did not know about it 😮

#

Might be very useful for the console messages and all this stuff

snow mango
# snow mango Using Netcode: I find that the speed of the client is lower than the speed of th...

I do have 2 types of inputs -> effects on my game:

  1. rotation = Quaternion.RotateTowards based on mousePosition (with rotationSpeed * Time.deltaTime);
    Works Great For Host Player. Same Speed as Offline

  2. position = Vector3.MoveTowards(MoveTowards(basePosition, basePosition - _tfBase.right, moveSpeed * Time.deltaTime);
    _Client Player Very Slow _

Both are Input, applied and sent to ServerRpc to apply to NetworkVariables in the same method

candid kayak
#

Hi guys, a C# tcp socket question here: when send data (object or serialized byte[]) with a message(define the data), what is the best way to send both of them?1: send two times one for message one for data. 2:pack the message into the byte[] using array combine at the begining of data or the end of the data,and break the array when receive it. 3:pack the message and object into a struct and serialize the struct.

#

4 use IList<ArraySegment<byte>>

feral oak
#

Does anyone know how to send an integer made by the master client to all the other clients? I'm using Photon and I have the master select a random integer, but I need that integer passed onto the other clients

spring crane
snow mango
#

can't figure out why my client movement and rotations are much slower than the host's

feral oak
feral oak
silk iron
#

I can pass int, string, bool...but I can't pass a class as a parameter in my RPC method call. I get an error when I pass in a class as parameter: Write Failed. Custom type not found.......

quiet ginkgo
opal tundra
#

Ok thanks

brazen canyon
#

Send the game object or view instead

stuck canopy
#

Hello. I am building a multiplayer game with a dedicated server and I have built the server as a console application. Is there any way to input into it?

polar meadow
#

Hi any champion here

#

Actually I need help can anyone help me

quiet ginkgo
#

Also, you could send data via the network.

glass steeple
polar meadow
#

@glass steeple ok sure

#

I want that my camera should follow the photon instantiated player

glass steeple
#

Cool

polar meadow
#

@glass steeple so do you have any idea about this

glass steeple
#

Do you have a script to follow a target?

polar meadow
#

Yes

glass steeple
#

Then set the player as the target

polar meadow
#

Did but not working

#

Ok let me show you the script

glass steeple
#

Are you sure your script is working?

polar meadow
#

Yes

glass steeple
#

Are you sure you are assigning the correct target?

polar meadow
#

Yes

glass steeple
#

How are you sure?

polar meadow
#

can i show you the script

glass steeple
#

You can try

polar meadow
#

Ok

#

GameObject target = PhotonNetwork.Instantiate(playertosp.name, spawnpoint.position, Quaternion.identity);

#

and here this.b = instplayer.target; //isntplayer is other script ehich takes the value of instatiated player

#

@glass steeple

full girder
#

I was following the Fusion 102 tutorial on the website, but I am getting an errors on the client's side, when I try to start the game
those are
[Fusion] ## Code Threw Exception ##

StartGameException: ServerInRoom

[Fusion] Failed Operation with Reason: ServerInRoom

silk iron
#

same problem

#

I cant pass classes

weak plinth
#

so when my player rotates the gun and hands rotate with it, but this only syncs on the x axis. how would i make it so that it syncs on the y axis too, so that players can see each other looking up and down? i have a transform view on the player controller object which is the parent of the hands and the guns

snow mango
#

When should I use Client-Prediction vs Client-authoritative?

#

My guess is that the first one is used for physics games?

somber drum
#

I don't mess with physics intensive stuff but I would imagine it's because physics game are much heavy and erratic, input is not as predictable

austere yacht
# snow mango When should I use Client-Prediction vs Client-authoritative?

Server authoritative if you need to worry about cheating or cannot trust the data a client sends for any other reason. Client authoritative if the state of an individual client has no negative effect on other clients or if you can trust all clients to be reliable and cooperative. Usually you end up with a mix of the two based on what the needs of the individual networked features are.

snow mango
austere yacht
# snow mango So it has nothing to do with physics?

if physics is non-deterministic (like unity physics) you can’t trust the individual client to produce the same outcome as another given the same inputs. So if physics results matter, you would want to sync those with a simulation on an authoritative server and use local physics only for high frequency prediction between ticks or for effects where minor differences don’t accrue enough to matter.

indigo thicket
#

Hello guys, is there a way to synchronize a serverside tilemap with MLAPI?

feral oak
#

Anyone ever made a random weapon/item spawner in Photon? Basically, a crate that a player would open and it would have a random item or items in it synced across for all players. I think I have a general idea of how I want to accomplish it, just wondering if anyone has so I could hear how they pulled it off.

true hearth
#

Hi everyone,

Anyone know how can I sync all movements of the clients with the server?

I tried with clientrpc but no work, the client no move and no does anything

Best regards and thanks advanced

true hearth
quaint moon
#

Do you need a separate build for the server and the client of your game? By the way, I'm referring to when your running dedicated servers (Playfab with Mirror Networking in my case). Based on MPSSamples provided by playfab it shows that it they used a seperate build for their client and server. Yet I've had a game work with just 1 build in my testing. If you need 2 seperate builds, why? What needs to be different in the server build and the client build

austere yacht
# quaint moon Do you need a separate build for the server and the client of your game? By the ...

its mostly a choice, maybe you'll do a build with different flags and optimizations even if client & server are essentially the same app. Generally servers that are decoupled from an engine are easier/cheaper to host, scale and integrate with other services. If a game has very complex shared/sync state and many details tightly integrated with the engine (effects and fast paced action) the development benefits of client/server being the same app might outweigh the operations benefits and more limited scalability.

gray pond
gray pond
runic rampart
#

@verbal lodge - I am consistently getting a crash when I've put a templated unmanaged struct into a ClientRpc, I imagine the code gen is causing a crash somewhere. Should I file a bug report on the repo?

sage valve
#

using photon:
when i connect 4 players its fine, but as soon as the 5th player joins, it says his buffer is full.
Got DisconnectMessage. Code: -11 Msg: "SendBufferFull". Debug Info: {}

when my players join, they all send data to the new player, including heavy stuff like their avatar png bytes.
is it possible to spread this "welcome package" out over time, or is there a better solution for this?

teal obsidian
#

if a user says "I just killed every person in the lobby" (in the form of a packet) the server will say, "👌" and kill every player in the lobby

#

In client prediction, each client only sends their inputs to the server. So like "request to walk forward", "request to jump", attack, etc. They predict what they're going to do and then reconciliate the state with the server when the next packet comes in. The server runs the same simulation as the clients, in order to verify the game state.

#

In client-auth, the client tells the server "im at pos x,y, z, doing x" and the server will essentially just believe you without much accurate checking going on

verbal lodge
quaint moon
#

How do you guys handle canvases with networking? Are your canvases part of the scene, or part of the player prefab, or what?

austere yacht
quaint moon
gray pond
quaint moon
quaint moon
#

In my case I’m using Cinemachine Virtual Camera. I only use 1 main camera but each player spawns with there own virtual camera

#

Idk if that changes anything

austere yacht
# quaint moon Idk if that changes anything

a camera is something that projects the game world onto a player's screen, if you do not have more than one set of eyeballs in front of that screen there is no point in ever spawning more than one main camera (unless you have a very innovative game concept that works differently than 99.9% of all games), you can keep your virtual cameras if you disable them while unused. Note that a virtual camera is something very different from an actual camera, so it makes a huge difference.

late swallow
#

Ok so, let's say I'm using mirror, p2p, and need the client to send some data like, updated avatar, to a Firebase database

#

How can I validate that data

#

And make sure the database is not exploited

#

I just really don't understand networking

#

Or for example, if I wanna retrieve some data from another player, but they have a setting for privacy on, that needs to prevent me from accessing it

#

Where and how do I verify that

#

Another question is, how do I know my networking code is optimized?

late swallow
#

So I would need the client to request that data, the server would retrieve it from the database, and then check if the bool is true or false, and return it's value to the client

#

Right?

high night
#

@late swallow Im thinking:
client -> backend -> database

#

client requests "get me the profile pic"

late swallow
#

What is backend?

high night
#

backend can respond with the image or return null

late swallow
#

I was told I need to use a dedicated server if security is important

late swallow
#

Using a server build?

high night
#

unitys server build can host the game
and the realtime information related to your game, like positions, healths damages etc

#

You might also wanna have a http server

#

Thats connected to a private database

late swallow
#

Oh god

#

Uhhhhhhhh

#

How

#

Do I do all of this-

high night
#

To handle your profile pictures, player stats

late swallow
high night
#

Inventories maybe

#

If I would do it, I'd host the backend in the cloud

#

I know how to use azure cloud services

#

I'd just go there and create a function app

#

And also find myself a database

#

Could be anything

#

Connect to your database via some secret key from the backend

late swallow
#

I'm using Firebase rn

high night
#

And you can have a nice backend app

late swallow
#

Could I use AWS?

high night
#

I think firebase can be both backend and the database

late swallow
#

Oh

#

Uhhhh

#

For a somewhat fast paced Unity game-

high night
#

You should be able to do something there that will prevent users from seeing non-public profile pics

late swallow
#

Yeah but I need some form of anticheat

#

And the host to not be able to run server commands

#

Meaning I need some dedicated server for the game logic

#

Not just for the database

#

Right?

high night
#

Thats a way different topic though

late swallow
#

Uhhhh

high night
#

That would be your realtime game server

#

Imagine these two connections:

#

.
client -> game server (udp/tcp based realtime connections):
game states and inputs are exchanged here

client -> backend (http requests)
profile information, friendship requests, trade requests etc exchanged here

late swallow
#

Oh okkkk

#

That makes sense!

#

I can use the Firebase API for the second one

high night
#

yes

#

firebase can be your backend

late swallow
#

One issue I had witu Firebase is that

high night
#

I never used firebase, i just know what it is vaguely

late swallow
#

When making an account, people usually add another field in the client for verify password and I don't think that's a feature in Firebase

high night
#

So I wouldn't know any firebase related details

late swallow
#

💀

#

Yeah