#archived-networking

1 messages ยท Page 110 of 1

jolly wadi
#

um should they do that

#

Thats not nice

#

tbh

spring crane
#

It's bold and risky in general

jolly wadi
#

yeah

spring crane
#

Not a lot of companies make direct claims about their competitor

jolly wadi
#

tru

spring crane
#

Yea they do sometimes, but you might open up yourself up for liability.

#

And afaik, they don't always do it, most likely because you wanna be damn sure you don't wildly misinterpret anything

jolly wadi
#

Man

#

Dont worry bout it

#

lol

#

yeah

#

ok it is a lot

spring crane
#

Do you have more than 20 friends playing at the same time?

jolly wadi
#

but what do you mean friend set up servers for their friends?

spring crane
#

You would have to pay for higher tiers if you want more CCU

jolly wadi
#

yeah

#

ok

#

but how many people do you expect playing

#

oh

#

ok i see

#

then you will have to buy higher

#

There is one networking solution that i started on

#

it is free

#

pretty much

#

other than the one time payment at the end

#

its steam

#

but it is really confusing

spring crane
#

Please send your messages as one message instead of splitting it into 5 ๐Ÿ˜„

jolly wadi
#

man that is hard

#

i talk alot

#

whats mirrors max connection?

#

oh

#

i thought mirror was always just for split screen games

#

me too

#

Does anyone know how to stop Photon Animations overriding my transform view?

spring crane
#

Yea no ๐Ÿ˜„ Mirror is a relatively normal networking solution

#

Are your animations using root motion?

jolly wadi
#

what does that mean

#

actually no

#

they are not

#

Wait what is root motion btw

spring crane
#

It's a concept in animation where the animation controls the position of the object, which helps with syncing the movement with the animation.

jolly wadi
#

Hmm so is this a good thing

#

cause there is a checkboxs

#

in my game

#

sorry for the lines thing i need to get used to that ๐Ÿ˜ฆ

abstract copper
#

Only you can possibly know if you want root motion enabled or not

jolly wadi
#

ok

#

let me try ig ๐Ÿ™‚

spring crane
#

Yea they are different approaches

abstract copper
#

Noticed you said you use FishNet.. Is it actually production ready? I was considering trying it out at some point

#

Or you know, maybe not full scale production ready, but at least quite viable compared to Mirror?

spring crane
#

This seems like a dedicated server <-> client architecture

#

It's also lower level than using one of these frameworks

opaque dew
# abstract copper Noticed you said you use FishNet.. Is it actually production ready? I was consid...

Sorry just got into the office. I started FishNet sometime throughout it's beta and a lot of ground has been made. The creator says there is a lot more planned but that it is fully functional and has every feature Mirror does. I do not recall their exact words, something about wanting to add more transports and documentation. I'm seeing they just recently finished their API documentation so I imagine guides are next.

olive vessel
#

It doesn't have every Mirror feature

spring crane
#

Finished or started the API documentation? I thought DocFX was just setup

opaque dew
#

I have a feeling if you asked the owner they would say no to being production ready, but I suspect that is to cover themselves before they go official. I've however had no problems or limitations using it for awhile now. It really is easy to use and they seem legitimate in their wants to make a good product.

spring crane
#

I guess documentation in the code mirrored on a site counts though

abstract copper
#

Yeah, the latter part of what you mentioned here is definitely why I am interested

#

very frequent updates and dev seems passionate

#

It also mentions future plans for many features I have wished for in Mirror, so glad to hear it actually seems to be quite viable

#

I will be checking it out, thanks!

jolly wadi
#

Thats a good vid by tom

#

ig

#

Erick Passos tho said it wasnt the best practises to my knowledge

#

Yeah

#

Technically

opaque dew
spring crane
#

What issue exactly did you have with Mirror?

olive vessel
#

I don't need a feature list, I donated to FishNet you know

spring crane
#

I don't think these really change the hosting situation

olive vessel
#

Is it whining about using Mirror LTS?

spring crane
#

I imagine most asset developers would like you to use non buggy versions of Unity ๐Ÿ˜„

olive vessel
#

Well I think most people would warn you about that...

spring crane
#

If it's just the latest tech release, Mirror is probably fine

#

Generally you want high amount of testing in projects that matter

#

In your situation, it's probably fine

#

You should test the hosting from a browser instance thing asap btw, since that has a high chance of screwing with your plans

#

MLAPI being released or not probably won't change that situation

#

Best case they offer free relay servers

#

If you are new to game development, singleplayer is definitely preferred.

#

That is how a relay server setup would work, yes. You can host server just fine assuming the person setting up the server knows how to change their network settings, which is generally beyond 99.9% of users.

#

To open the port

#

and have the port open, yes

#

Not just system, but generally router settings

#

You can see the general process by looking up how to setup servers for other games, like CS, Minecraft, etc.

mortal horizon
#

@weak plinth you can use mirror + epic online services for free relay server (player hosted games)

#

Thats about all you can get for free though

#

Yeah its completely free. Ridiculous I know lol

#

Check out # epic channel in mirror discord

#

Yeah just Google mirror discord you should be able to find it. Can't post invite links here i don't think :)

#

Lots of people have been using it, it seems like it works good

covert creek
#

Im working with MLAPI, and im making a simple multiplayer fps. I'm having issues with each player controlling the correct character, for now either everyone is controlling everyone or (after some attempts to fix it) everyone controls the same character.

vocal ferry
#

remove nonlocal cameras

covert creek
#

what does that mean?

astral gull
#

May I ask, which objects should be server - side and which client side in an rpg on dedicated server? It's just, I got an error - "disconnected cause of clients logic" - what could it be?

indigo thicket
#

Thanks, it worked well!

#

I'm having another problem: how do I change the parent of the spawned object? I need to attach a spawned item to his player's prefab, but seems like instantiating it with the player's transform doesn't work: the item is correctly set as a child object in the Server/host, but the clients keep the item without a parent.

jolly wadi
#

Well it is easy if I can explain right

#

Basically you wanna in the script of the object type

#

gameObject.transform.SetParent(the transform of the object you want to parent it under);

indigo thicket
#

Yeah, it doesn't work

#

It changes that for the server, it doesn't change that for the client

jolly wadi
#

Really

#

Are you calling it on the server

#

You must be

indigo thicket
#

It's on a ServerRpc, so yes

jolly wadi
#

Send it to a client

indigo thicket
#

    [ServerRpc]
    public void EquipServerRpc(ulong clientId, int itemId)
    {
        if(equippedId >= 0)
        {
            NetworkObject player = NetworkManager.Singleton.ConnectedClients[clientId].PlayerObject;
            var item = Instantiate(InventoryManager.Instance.itemPool.getItem(itemId).equippedPrefab, player.transform.GetChild(0).gameObject.GetComponent<PlayerController>().objectInHand.transform);  //This works for the server
            item.transform.SetParent(player.transform.GetChild(0).gameObject.GetComponent<PlayerController>().objectInHand.transform); //This also works for the server
            item.GetComponent<NetworkObject>().Spawn();
            item.transform.SetParent(player.transform.GetChild(0).gameObject.GetComponent<PlayerController>().objectInHand.transform);//This also works for the server
        }
        else
        {
            NetworkObject player = NetworkManager.Singleton.ConnectedClients[clientId].PlayerObject;
            Destroy(player.gameObject.GetComponent<PlayerController>().objectInHand.transform.GetChild(0));
        }


    }```
indigo thicket
#

Do I have to call a clientrpc and set it in every client?

jolly wadi
#

Not really

#

Yeah

#

Idk tbh

indigo thicket
#

How do I select an object with the networkId?

#

I mean, I have to tell the client which object has to be set where, but I don't know how to select the object (knowing his NetworkId on serverside) and the docs don't explain it

jolly wadi
#

Yeah

indigo thicket
# indigo thicket How do I select an object with the networkId?

Ok I can't even select different player prefabs outside the owner's player prefab, if I'm not the server. Is there literally any way to select an object in MLAPI with a network id/client id? I need to use it in a client rpc, so no "ConnectedClient[]" dictionary can save me...

jolly wadi
#

Wait

#

Are you trynna set it on every client

indigo thicket
#

Well, yes?

#

I'm trying to equip an object

#

so every client has to see that a player has equipped the object

#

since networkobject can't change the parent (outside of the local space) and, in every case, a networkobject can't have another networkobject as a parent, I must spawn every object locally

#

but without access to ConnectedClients, as a client, I can't tell to every client "ok spawn this object at this player"

#

I can do that only in the host, because he's the server

jolly wadi
#

Damn MLAPI is confusing

indigo thicket
#

and it's really young, so no tutorials/posts in the forums can help me T.T

jolly wadi
#

Yeah I have barely used it

#

The only thing I did was import it into a project

barren onyx
#

I'm still confused on how to use MLAPI at all too.

#

Even I've followed the documentations, I still have yet to understand how I can get the client to join the host ๐Ÿ˜ฆ

shut yarrow
#

No idea what you're trying to achieve but could you briefly tell me what exactly you want to do with MLAPI?

barren onyx
#

I'm trying to create a network lobby for players to join.

shut yarrow
#

Note that I haven't used it myself

#

Is it player hosted?

barren onyx
#

Yes

#

Debug log confirms this.

shut yarrow
#

You have access to a server?

barren onyx
#
 void OnEnable()
        {
            if( !ClonesManager.IsClone() )
            {
                NetworkManager.Singleton.StartHost();
            }
            else
            {
                // this should connect you to the host?!?
                NetworkManager.Singleton.StartClient();
            }

            Debug.Log($"Lobby On Enable - IsClient: {IsClient} | IsHost {IsHost} | IsServer {IsServer}");
}
#

On one project, It starts up as a host, which shows all three variable true. On the other project it joins as a client, which only client shows up true. Yet I have event handler that should display a message stating that a player has joined the host

#

So I feel like there's something lacking out of that documentation. I'm trying to check out Boss room example Unity provide and ingest information from there.

shut yarrow
#

I'm afraid I can't help with MLAPI but I wanted to ask if you're interested in trying my library that I'm working on

#

It's not player hosted but it does allow players to make/join rooms

#

I'm curious if I managed to make it simple enough so people are willing to try it

#

Let me know and I'll help you get going. Multiplayer is complicated as is and all the options don't make it easy I can imagine

#

Feel free to dm me

swift epoch
#
    [Client]
    void Update()
    {
        SpawnCommand(hit.point, cam);
    }

    [Command]
    void SpawnCommand(Vector3 position, Transform cam)
    {
        GameObject enemy = Instantiate(enemyPrefab);
        NetworkServer.Spawn(enemy);
    }

I'm using Mirror, and attempting to spawn an enemy on the server when the user presses a key (For testing, I'm just doing it in Update() on the client). This is giving me the following error:

Trying to send command for object without authority. SpawnEnemy.SpawnCommand
UnityEngine.Debug:LogWarning (object)
Mirror.NetworkBehaviour:SendCommandInternal (System.Type,string,Mirror.NetworkWriter,int,bool) (at Assets/Thirdparty/Mirror/Runtime/NetworkBehaviour.cs:115)
SpawnEnemy:SpawnCommand (UnityEngine.Vector3,UnityEngine.Transform)
SpawnEnemy:Update () (at Assets/Scripts/Enemies/SpawnEnemy.cs:24)

Line 24 is SpawnCommand(hit.point, cam)

#

So you need authority to run a Command, right? But how would I do something based on user input without the user having authority?

swift epoch
#

Got it. Since it spawns for everyone, it doesn't matter who actually presses the button, so I just replace [Client] with [Server] and put it all in there

indigo thicket
#

I've done a lobby in my game so I can help you!

#

(however I didn't add the password, so if you want that you have to look it up online)

#

By the way, with my problem (selecting a networkObject by networkId, in MLAPI) I found that the docs have this:

#

"When a NetworkObject is considered "Spawned", it is replicated across the network so that everyone has their own version of the object. Each NetworkObject gets assigned a NetworkId at runtime, which is used to associate two NetworkObjects across the network. For example, one peer can say "Send this RPC to the object with the NetworkId 103", and everyone knows what object that is."

#

But there's not written how do to that T.T

cloud nest
#

I followed tutorial how to do quick matchmaking but void OnJoinRandomFailed didnt works (i am using photon)

cloud nest
#

i did it it works

granite yew
#

Hey how can I call an RPC function to only yourself instead of all players? in photon

spring crane
#

Can't just call the function directly? You can pass in target player instead of using RpcTarget

knotty heart
#

Anyone using LiteNetLib here ?

#

I added it... under plugins but the namespace is not recognized

#

Any ideas why ?

indigo thicket
#

Is there a way to synchronize only the rotation of an object ignoring the position, with my networktransform component? (MLAPI)

#

I need to sync the rotation of a child object, but if I place a networktransform the position of the child object is "delayed" against the position of the parent...

dusky storm
inland sand
#

Is unity mlapi out?

olive vessel
#

Preview versions are available

granite yew
#

Hey how would I change a float value which is a value of the player's weapon accordingly depending on which weapon the client chose

hasty pendant
#

Please is uNet still working??

olive vessel
#

UNet is deprecated, you should look into other solutions like Mirror, MLAPI (Netcode for GameObjects) or Photon products

astral gull
#

May I ask, how to fix this code? I think I understand that to fix it I need to somehow reference that the player is local while not on the player but on the server... but how?

 [Command]
        private void CmdUpdateL()
        {
            if (isLocalPlayer)
            {
                    StartCoroutine(AttackCo())
            }
        }
--------------------------------------------
[ClientCallback]
        private void Update()
        {
            CmdUpdateL();
        }
south palm
#

I'm getting the following error
NetworkServer is not active. Cannot spawn objects without an active server.

#

whenever I try to call NetworkServer.Spawn(obj);

#

what am I doing wrong?

#

i'm using Mirror btw

#

the player with this script on it has client authority

mortal horizon
#

only server can spawn networked objs

#

you need to send a command to the server or have the server context call it

south palm
#

ok that got rid of that error. I'm now getting:

barren onyx
swift epoch
#

Using Mirror, how can I find what user pressed a button but still do something on the server? I need a script on my GameManager to spawn an enemy at the center of the screen when a user presses E

If I do this using a command, I get a "tried using a command without authority" (That text may be incorrect. I've been tinkering with this for a few days so I can't remember the exact text) error, but if I use a [Server] thing, I can't get the user that pressed the button

shadow spoke
#

Hash Sets are something I am not fluent in, but SyncDictionary should be pretty straight forward ๐Ÿ™‚

barren onyx
#

HashSet is just Dictionary, but only based on unique property.

#

E.g. Dictionary<string, item>, whereas HashSet<Item>

#

Identical elements are prohibit in HashSet.

shadow spoke
# swift epoch Using Mirror, how can I find what user pressed a button but still do something o...

Use a command function type to instruct the server to carry out something.

private void PollInputs() {
  // Example.
  if(Input.GetKeyUp(KeyCode.E)) 
    LePushButton(true);
}

[Command]
private void LePushButton(bool selfDestruct) {
  // Code here runs on the server world, do whatever.
  if(selfDestruct) 
    Oops();
  else
    DoSomething();

  // Tell the client we pushed the button.
  LeButtonPushed();
}

[ClientRpc]
private void LeButtonPushed() {
  // Explosions go here.
}
shadow spoke
swift epoch
shadow spoke
#

Seems to me like you're likely missing either a "isLocalPlayer" (I think it might have changed wording in Mirror) check as it seems like another object is also picking up inputs from the local player (which is bad - short-circuit any input polling for non-local players or you may get really weird behaviour)

swift epoch
#

If I use that, it just doesn't run at all

shadow spoke
#

I'd need some more info, where is your script attached to the object?

#

on the player, or camera?

swift epoch
#

The script is on the GameManager object. It's SpawnEnemy (It's enabled at start)

shadow spoke
#

And Game Manager is owned by whom?

#

The server? Or the client?

#

If it's owned by the server, then of course - you have no authority (access rights) to run that command.

swift epoch
#

Client

shadow spoke
#

You'll need to move the spawn script to your local player object.

#

That's why you're getting that error.

#

You're trying to call a function on a object that you have no control over, because Game Manager is "owned" by the server/host

swift epoch
#

This is on GameManager, a script attached to the Game Manager object. OnJoinGame() is ran by the players when they join

swift epoch
shadow spoke
#

Why is the client assigning authority to itself?

swift epoch
#

That's from my testing

shadow spoke
#

OK

swift epoch
#

Ignore that line, it did nothing

#

It's been 4 days. I'm trying absolutely anything

shadow spoke
#

Alright, so tell me your end goal, spawn a object on the server, right?

swift epoch
#

Yeah, at the center of the sceen of the user who pressed E

shadow spoke
#

Do you need the GameManager to run the spawn code, or are you happy for me to condense it down into just a single script?

#

So you attach and boom, you can spawn enemies from the player?

swift epoch
#

I would prefer a solution that can be run from other objects, so I don't need 400 scripts on the player object

shadow spoke
#

Alright. I'll work my magic. Note that this will be super crude but it'll work.

#

@swift epoch does the client require authority over the spawned object?

swift epoch
#

Not this one in specific

shadow spoke
#

ok, i'll omit that.

shadow spoke
#

Alright, testing locally now

shadow spoke
#

Done.

#

So basically, I have two scripts. One is your game manager that does the server-side spawning. The second is a script you attach that then tells the server's copy of the player object to tell the game manager to spawn a object at a random position. I'll throw this onto a Gist for you. I have sprinkled some comments that should be easy to follow.

#

Tested and zero spawn problems.

swift epoch
#

Thank you so much

shadow spoke
swift epoch
#

I'll have to test it in a few minutes. Thank you again

shadow spoke
#

It's super basic but you could very well rig it so you grab a raycast position from your camera

#

then tell the server hey i want to spawn it there

#

but yeah, the basis is there. Definitely good enough for prototype

swift epoch
#

I was finally able to test it. It worked perfectly!

weak plinth
#

Anyone work on Nakama architecture/networking have some time for a few questions?

shadow spoke
#

Glad to hear it, Pinto ๐Ÿ™‚

modern drift
granite yew
#

Hey how do you synchronize float values so if player 1 has the float value set to 3, other players can see his value set to 3?

placid escarp
#

Hello guys, i hope you have a wonderful day
i used Photon to make my first multiplayer game prototype
Anyone knows why Players positions are a little bit off in different clients? (Compare using the grid on the floor)
Thank you

livid vale
#

Does anyone know the official unity mlapi discord server? the links on the unity forum and blogs are broken.

placid escarp
livid vale
#

Ah this one is working, thanks alot ๐Ÿ™‚

spring crane
#

Link also in the pinned post

silk helm
#

Hey guys, is it possible to override OnLeftRoom() in photon?

sterile inlet
#

I need help with a problem I can't fix.

If my player disconnects I want to destroy his Player GameObject, if he leaves with button It works. But what if someone closes the game and disconnects by that action.
How do I get his Gameobject?

#

And destroy it ?

#

With Photon btw

normal dust
#

Using MLAPI, I want to send a lot of information from the host to 1 client. Right now I do a serverRpc to get all the hosts information I want to send, then I do a clientRpc with if(!isOwner) { return; } so the client that sent the serverRpc gets all the information. But I want to know will the other clients be sent the information too because I'll be putting all the info in the method. I know they wont do anything with the information but I want to know if this way is the best way. Like I don't want to call clientRpc with a lot of info to every client, just 1. IDK if the method with a lot of information will be sent to everyone. Hard to explain. I just don't want to use a lot of bandwidth sending all this information to every client just for them to say, oh, return. I just want 1 client to be sent to and receive it.

swift epoch
swift epoch
#

This is a script that creates a "dumb" enemy AI. It just constantly moves toward the nearest camera. It's attached to the enemy's prefab so only runs while one is spawned

For whatever reason it creates the following error on the client

[Server] function 'System.Void MovRotScript::Update()' called when server was not active
UnityEngine.Debug:LogWarning (object) MovRotScript:Update () (at Assets/Scripts/Enemies/MovRotScript.cs:25)

Can anyone help me figure this out?

#

Putting if (!NetworkServer.active) return; in Update() did nothing, presumably because the actual Update() function itself is still running

sterile inlet
#

try put if(NetworkServer.active){put everthing inside}

#

how todo these cool code snippets?

shut yarrow
#

That'll give him the same error

#

Like he says the update function would be called regardless and print that error when server isn't active

swift epoch
#
// CODE

It's the backtick. On the same key as ~

shut yarrow
#

Not familiar with that API though so no idea about how it works

#

Looks like Mirror to me but not sure and haven't used it before

swift epoch
#

It is Mirror. Apparently it's very similar to UNET, though

swift epoch
shut yarrow
#

So do you know where Update is being called from initially?

#

The Server attribute gives me the suggestion that it's automatically called from somewhere

swift epoch
#

I forgot to mention that error occurs every frame

shut yarrow
#

Double click the error it might lead you to where the error check is taking place and perhaps give you some more information

swift epoch
shut yarrow
#

It's a NetworkBehaviour so I'm kind of assuming it's being registered somewhere by Mirror

swift epoch
shut yarrow
#

Alright nvm then it was worth a try ๐Ÿ˜›

shut yarrow
#

Do you know what the Server attribute does?

#

Without any background I'd think it's being called every network tick by the server but I could be wrong

swift epoch
shut yarrow
#

Or let me put it different. What would happen if you removed the attribute from the method?

swift epoch
#

I can't find any documentation on what that error actually is, so I don't know if that's what's happening, but if (!isLocalPlayer) does nothing

shut yarrow
#

You might find it on their github

swift epoch
shut yarrow
#

So if I understand it correct, you'd use this for something like an NPC that nobody owns but the server?

swift epoch
#

Yeah

#

It's just a dummy enemy

shut yarrow
#

I see

#

But it is synced with everyone I assume?

swift epoch
#

Yeah

shut yarrow
#

Does this script or object have any input scripts that allow it to function? Otherwise you might be able to get away by removing the Server attribute because nobody could control it anyway

#

Just trying to think outside the box though since I have no idea how Mirror likes you to do things

swift epoch
#

I could do that, but then on one player's screen the enemy could be walking in one direction and on someone else's it could be walking somewhere else

shut yarrow
#

If you remove the attribute that could happen?

#

Kind of weird

swift epoch
#

Well it'd be rare

#

But say the enemy collides with a player, and this packet is lost for one player. Well now they're desynced, so it could be way off somewhere else for that one player now

shut yarrow
#

Does Mirror have a NetworkObject component (similar to PhotonView)? If so then you should be able to check if you're the owner or not

rough garden
swift epoch
#

I believe NetworkIdentity or NetworkTransform is the equivalent

rough garden
#

btw has anyone tried mlapi? i have been looking at a few solutions (mirror and photon) but not sure which to commit to. i'm looking for something that can allow me to do server auth stuff but not cost an arm and a leg. any suggestions?

shut yarrow
#

Alright so maybe that could be an alternative way to check whether you're allowed to control the object or not. What this means in terms of synchronization is a completely different matter however ๐Ÿ˜›

#

I've only tried Photon before deciding I'd make my own networkingsolution

swift epoch
#

Completely different emotion conveyed by that edit

#

I tried using ServerCallback instead of Server. ServerCallback isn't supposed to create an error when a client tries running it. This stopped the error

So I believe the issue is just that the client tries running it as well. I guess that actually gives somewhere to start

shut yarrow
#

If it still does what you expect it to do without the error then it should be good enough I suppose

inner acorn
#

the best way to fix networking in unity is to simply ||use unreal trollface ||

shut yarrow
#

You know there are tons of networking options out there you can choose from right. If you think you can/should only use what the engine gives you then I don't know what to say

jolly wadi
normal dust
#

Using MLAPI. client calls a ServerRpc, Will the ServerRpc find the hosts data if I run programming here? Or do I need to call a ClientRpc in the ServerRpc and do if(!isServer) { return; } then get data I want from host? If this makes sense.

vestal python
#

Hello. How can I get all player position in a multiplayer game using Mirror?
Thank you.

dusky storm
swift epoch
#

Wouldn't they need something similar to if(object.TryGetComponent<PlayerController>()) to distinguish players from non-players?

modest light
#

hello guys,I want to learn how to make a side-scrolling mmorpg, but I canโ€™t find a suitable article to learn server related information from the beginning, Can anyone recommend me any articles?

dusky storm
#

itโ€™s not that difficult anymore compared to 5 years ago

normal dust
#

MLAPI. Open world game. Im trying to send 200k bools to a client to disable any changed objects in the world using Rpc but it says limit 1.4k... And im not using .Spawn() because clients cant collide with the objects. Bit lost on what to do.

verbal lodge
#

200k is a lot. You will probably have to use a custom message for that. Is there no way you could send this information in another way like only send the objects which are in chunks close to the client?

normal dust
#

Idk how to do that. But i can look into it.

#

This is only 1/5th of my world done. Im scared now lol.

odd flower
#

must i use networkvariable for client+server side variables?

olive vessel
#

If you want the variable to be synced, yes

odd flower
#

and unless there only client sided?

olive vessel
#

Just a normal variable then

odd flower
#

so i must all variables change to networkvariables

olive vessel
#

If you want all variables to be synced

#

So the answer is no, you likely don't want all variables to be synced

odd flower
olive vessel
#

Position is handled by the NetworkTransform

#

Health is a good example of a NetworkVariable

#

Not sure what that means

#

When in doubt, check the docs

astral gull
#

May I ask, I'm trying to follow additive scenes and there's a line that says "add subscenes to the list" so I wanted to ask - does menu scene count as a subscene? then what about the main scene? I have three scenes in my project, main, subscene and menu.\

weak plinth
astral gull
#

that creates a list where I can add and remove scenes.

#

but I have no idea what counts as a sub scene and what not

weak plinth
#

I would assume anything that loaded in during runtime

#

would be a subscene

astral gull
#

so its main game scene and subscene... or is it menu and subscene? I'm confused xd

#

or even all three of them

weak plinth
#

Whatever is the first scene loaded in by Unity would not be a subscene. So maybe you start with like a bootstrap and then MainMenu, Level1 etc are subscenes

astral gull
#

The first scene that is loaded is menu so I think I will add main game+subscenes to subscenes... Ok, thank you ๐Ÿ™‚

weak plinth
#

That would be how I interpret it yea.

#

Might be worth though having like a bootstrap scene just for loading additively into because I assume after your game you will want to return to the main menu

astral gull
#

So, I have this error "the scene object down hit box has no valid sceneId yet" and don't know what to do with it.
Can somebody please help?

keen mirage
#

Has anyone have experience getting data from google fit to use for your game?

astral gull
#

May I ask, how to fix Prefab 'Player' has multiple NetworkIdentity components. There should only be one NetworkIdentity on a prefab, and it must be on the root object.
if scripts of children depend on identity?

wind citrus
#

Hey all, i have a class that inherits from NetworkBehaviour but it doesnt know the [Command] attribute. Does anyone know why?

olive vessel
#

What networking solution?

wind citrus
#

?

granite yew
#

Hey, for my multiplayer game I have a arresting mechanic which players can place handcuffs on other players, making them unable to move. How can I make this system?

olive vessel
#

You could have some network variable like isHandcuffed and if it's true, don't let them move

#

Obviously this would only be set on the server

#

Client just needs read perms

shadow spoke
#

In your input logic, you'd just do like...

#

if(isHandcuffed) return;

#

if it's a function that feeds input data back to whatever.

weak plinth
#

can some one help me how i make character selection in Unity Pun ?

spring crane
#

@weak plinth Create CharacterDefinition ScriptableObject that has all the information about the character and give it an ID of some kind, most likely int. Send that ID whenever you want to communicate a specific CharacterDefinition over the network. Receiving clients can go through all the CharacterDefinitions to turn the ID back into a CharacterDefinition.
You can apply this sort of setup to a lot of things, like maps, items etc.

#

At least when it comes to static data.

fiery ravine
#

It doesn't allow me to creat a room and idk if that warning is the problem

olive vessel
#

Put helpful debug logs in each method to check what is being called

weak plinth
#

Iโ€™m trying to create a kill feed/kill counter with Photon PUN 2, does anyone know a really good tutorial/know how to go about it and could help me with it?

fiery ravine
olive vessel
#

Then you didn't add them very well did you

#

It isn't debug.log btw

weak plinth
#

waits patiently

olive vessel
#

Tells you to stop roleplaying and use Google, that is a well documented thing you want to do

weak plinth
#

.-.

vital rivet
#

Hi, Does anyone know how I can check if a player is on an internet site? It could be any website, I just need to know if it's there.

fiery ravine
olive vessel
#

Yeah, did you use it correctly?

#

Show us

fiery ravine
olive vessel
#

So the answer is no

#

Semi colons

fiery ravine
#

omg sorry

fiery ravine
#

is there something wrong here

#

it can't creat a Lobby for some reasons

olive vessel
#

You do create and join a lobby

#

You don't even try to make a room

jolly wadi
#

You havenโ€™t classified the room options

fiery ravine
jolly wadi
#

Try something like

#

RoomOptions room = new RoomOptions();

#

And then when you create a room pass through room

stray solar
#

How can I connect to a ngrok tcp tunnel?

granite yew
#

Hey how can i change enums throught all clients when a player presses a button?

olive vessel
#

Depends on the networking solution

#

You can use RPCs or NetworkVariables, depending on networking solution there will be subtle differences with how you implement them

granite yew
#

I use photon

olive vessel
#

Then you should look into synchronising variables in Photon, not sure how Photon does all that tbh

wicked barn
#

IM making photon networking and it it a rigid body locomotion base where you use the force of your hands to move around and when the 2nd network player spawns there is no model attached to the rig

granite yew
#

do u have a photon view on ur player?

sterile turret
#

Hi all, I'm trying to use photon fusion's NetworkCharacterController in place of the default Unity CharacterController to get an extant character asset working in a multiplayer setting. Everything's working smooth, just trying to parse a method that gets the platform the player is currently standing on. In the original script it used MonoBehaviour's "OnCharacterColliderHit" to pull the hit.Collider.Transform. Photon seems to have a similar method for its networkCharacterController (OnCharacterCollision3D) and I'm trying to pass the same along, and I think my error might just be one of syntax. Am I calling this method correctly?

ancient lantern
#

Hello. I'm having some issues figuring out the best solution for networking.

A little background knowledge: I'm trying to start working with Unity (I now have about a week of experience with the UI, package manager, creating various things like prefabs and materials, etc. and can say I feel comfortable working with GameObjects, scripts, and basic interactions between parts.) I am trying to create a 3D game from scratch. I have another game in 2D, but it was written in TypeScript with Angular, Node, and WebSockets. I use a couple libraries there which make networking absolutely easy.
The problem is, I can't seem to figure out the best solution when it comes to Unity. Whereas in my other project I can simply send and receive updates to/from the server based on actions on either and invoking a simple function within the client or the server's main objects, this doesn't seem to be at all the case with Unity.
I have now went through a few options but the biggest thing holding me back is persistent data. I cannot find any solutions (except writing my own sockets and networking code from scratch and I don't have enough experience to do that yet.)
I've tried Photon, which works extremely well, but has no persistent data. I've tried MLAPI but, well, I think we can all agree on that being an issue, although it did work partially. I've looked into Mirror but haven't used it yet, as it looks similar to the others and still can't find any info on storing persistent data.
The requirements for the solution would be:

  • Storing persistent data.
  • Spawn them in the last position and map they left in, and with which character they selected (character customization) before joining the game.
  • Mostly just normal data types. The biggest thing I think I would need to send is the different character options they've selected (an object containing ints and strings and maybe an array of ints or two) and the position in the game, action taken and basic chat.

Once I have networking, I think I will be able to continue on my own for most of the rest of the development, but networking is a base requirement for the game being made.

I'm not used to asking for help (as I try my best to learn everything on my own,) so if this is long or formatted incorrectly or anything, my apologies. Also, if it's easier, you can DM me to discuss this. Any help with this is appreciated.

gleaming prawn
#

Discord

shut yarrow
#

@ancient lantern there's a reason none of the mentioned libraries have persistent data, because that's typically handled by the server (or even the client itself sometimes) rather than the framework. These frameworks give you means to send/receive data, but it's up to you to decide the conditions when this should happen. You most likely want to have some kind of database to store persistent data, where the database is the storage unit and the networking framework is just the medium to transfer it from A to B.

ancient lantern
# shut yarrow <@!524703747985899541> there's a reason none of the mentioned libraries have per...

I think where I get most confused is by the fact that most of the implementations I see have a single Unity project that contains both the client and the server inside of it, otherwise you're writing it from scratch (I don't have enough experience for that.) I was looking for something that I would imagine is more performant than that, and having to fork/clone/write build scripts that produce larger code than it really needs to be.

shut yarrow
#

Those kind of projects in my opinion are for demonstration purposes only, but you're absolutely right because in production nobody would ever use such setup because it's not efficient enough. There is quite some abstraction involved to get many different systems working together, and having a server for the sole purpose of doing database stuff isn't unheard of. It all depends on the size of the system however, main take away is that database often stands on its own and knows little or even nothing about the game itself. The server does the interaction with it, and gets/set data from/to it when it needs to. It doesn't even need to be that complicated either. A database could just be some kind of data structure in your server application, but in normal circumstances when the server shuts down the data is lost (unless you write to disk).

gleaming prawn
#

That strongly depends on what you are trying to build

#

@ancient lantern you get games like Fortnite, Pubg, CSGO, Valorant, where server/client are written on the SAME project

#

the server runs almost same code as client, etc...

#

The most common case (if you can call that common) where you write separate projects for server and client are actual MMOs, because the engine code would not scale to the sheer number of clients you need to handle.

#

But that is far from what most online games do...

#

As the others stated already, persistence is normally dealt with almost agnostically to what is the solution you are using for online synchronous gameplay (the libraries you mentioned deal with the later only).

#

Also notice photon is a company, not a product, so I assume you were talking about PUN2. I suggest you look into the higher end solutions by photon like Fusion and Quantum.

#

Just one point Swanson:

#

but in normal circumstances when the server shuts down the data is lost (unless you write to disk).
The point of the DB is to NOT loose the data

#

Otherwise you don't even need the DB

shut yarrow
#

If the game is relatively simple and PUN(2) serves your needs you could also rent a webserver which can store data for you, and interact with it through http requests

#

You're right I was merely trying to make the point that a database can be in memory only as well

gleaming prawn
#

in short:

  • mmos, server is normally a separate project, not using Unity
  • regular games up to 200 or so players, server is normally a unity instance, using same project (or deterministic, which does not need an engine server - special case)
  • in BOTH, DB is a separate thing, used to persist game state when servers are shut down...
gleaming prawn
#

db in memory is a good way to simplify the implementation of these, as you can rely on SOME of the DB features (like searches) for some gameplay stuff, arguably

shut yarrow
#

If it's not super crucial data then it could be sufficient and it's super fast and easy to do

gleaming prawn
#

yes

#

Just wanted to add some more info I hope is helpful. You are giving good advice...:)

shut yarrow
#

Thanks I appreciate that. There are plenty of choices for him and it could be very simple depending on what his requirements are

ancient lantern
#

Well, ultimately I think I will need a high performance option in the future, I may get upwards of 50-possibly a few hundred, maybe more, on a single (large) map and server at once. Something like Silkroad Online (the real old game, not the other site) where you spawn in and there's just people everywhere.
The persistence is needed because there will be character customization in the game, as well as chat, and other player data. I also just really don't want to limit myself in the early stages of development and then have to rip out the old networking and replace it later, introducing bugs.

Also, it surprises me- If that's true- That those big titles actually build in the same project like that. I mean, the server/client code in my other project is technically in the same project, but the TS and Angular compiler pick and choose which files and components they actually need during the build time. Unity has no apparent method of "just include the server stuff" during build.

Also. What about the DB stuff being on both client and server? Would a simple "!IsServer" check be enough to disable DB on clients, or how would that work?

shut yarrow
#

The database will be for the server only to talk with, then the server forwards any information to clients when needed. Clients should not ever have access to this database

ancient lantern
#

Another question with it both being client/server in a single project, is what about decompiling and looking at the code? It also seems to be a bit of a security risk if I make a mistake.

shut yarrow
#

That's a never ending battle and speaking from experience, not even having to look at assembly code is going to stop someone if he really cares to break stuff

#

You want to prevent exposing critical elements to the client

#

So best they can do is make (bad) assumptions on how something works and even if they know how it works they will have to break into the server to exploit it

#

But in popular games people will cheat, it is what it is. You can go out your way to prevent that from happening but it's a tough battle regardless of what you try to do about it

ancient lantern
#

So host DB on machine with server (separate process like MySQL or something,) Unity code only contains access to it (I was thinking about using the built-in Unity storage if I go this route but let's not go there yet,) use environment variables, arguments or something, and then no matter what the client does, it's firewalled, I guess? Oh yeah, and does Unity have support for .env or anything to store credentials? >n<

shut yarrow
#

Unity uses the .net framework which allows you to create any file you like

#

And yes, host database on the/a server where nobody would even know of its existence

#

However don't get caught up on the idea that the server has to be a unity instance as well. The only reason I can think of why you'd want that is when you want the server to do all the physics, this is also the most expensive way of doing it

#

I have a physics based game but the server itself knows nothing about physics, it's a console application that pretty much knows nothing about unity at all

#

I've yet to see however how many clients it can serve

#

It only uses a couple of megabytes of memory and barely any CPU which is a good thing

ancient lantern
#

That's exactly what I'm aiming for, really. Just a console (I know about headless Unity builds but still, Unity backend) that serves clients. As for physics, I did actually want some sort of anticheat at some point added, but nothing more than "they just can't teleport across the map" kinda thing.

shut yarrow
#

But as you can see there's so much to it and it's impossible for a single person to walk this minefield without getting hurt. Try to learn from your experiences and see where things fall short, is all you can realistically do at this point

austere yacht
#

Expect to fail multiple times for unexpected reasons

shut yarrow
#

Yeah I personally don't feel much for doing all this anticheat type of stuff, I do the low hanging fruits because I don't have the expectation that my game will be popular all of a sudden. There's so much more for me to learn about and getting stuck on fighting cheaters isn't much fun

#

I believe more in giving some trusted players privileges so they can deal with cheaters when needed, these players who play your game a lot are incredibly valuable

austere yacht
#

When you have to worry about cheating you already work for a company with popular IP and get a 6 figure salary

shut yarrow
#

That's the dream we chase ๐Ÿ˜„

ancient lantern
#

If I have learned one thing from my other game and running Minecraft servers, it's that you need to expect cheaters eventually. Lol. I try to be thorough in the beginning instead of worrying about it when the server is on fire and those players can't play anymore.

shut yarrow
#

Yeah if you have more than just a handful of players then you can expect someone to try and cheat

austere yacht
#

Tilting windmills though

gleaming prawn
#

like #IF SERVER_BUILD, etc

austere yacht
#

I mean do the reasonable thing, server authority and such, but donโ€™t worry about stuff that hasnโ€™t got solutions in your reach

gleaming prawn
#

yes... exactly the above

#

For example, aim-bots are normally something you do not DEAL with when working with NETCODE

shut yarrow
#

Needless to say not even most of the popular titles have their shit together, they made a wager that they'll profit more by just not putting in all the effort to prevent cheating, they are already working on the next title and repeat the trick and everyone buys into it

gleaming prawn
#

If you ever will deal with that, you need to involve: memory anti-tampering and/or pattern-recognition on server

austere yacht
#

Client&server as separate projects is adding a lot of wasted effirt imo

gleaming prawn
#

but apart from aimbots, most other cheat stuff can be dealt with by doing proper server authority, etc

ancient lantern
#

xD
Anyway, I've pretty much got a plan in mind, now my only remaining question, is Mirror still good, or should I use another stack? I tried MLAPI but it's just painful and incomplete and the documentation matches that state.
Also didn't know that Unity had the option of build flags in the code like that, I'll have to look into that.

gleaming prawn
#

My biased suggestion is: try photon fusion

#

disclaimer, I work at Photon

#

Because fusion has things like client side prediction, snapshot interpolation, lag compensation, all turnkey

austere yacht
ancient lantern
#

I did consider the WebHooks method with Photon actually. But it seems like an extra server to me.

gleaming prawn
#

that is not something we at photon recommend at all...

#

WebHooks for dealing with authority is really not related...

ancient lantern
#

How else do I store persistent data while hosted with Photon?

gleaming prawn
#

If you are worried about server authority, go for Fusion

gleaming prawn
#

As everybody said here, persistence has not much to do with netcode gameplay

#

It's a different problem

ancient lantern
#

Yes, but the server must have the means to actually write to/access a database.

gleaming prawn
#

yes... but that is mostly Unity, does not matter which netcode solution you choose

#

to be clear, all the products below let you run a Unity instance (dedicated or player hosted) as authoritative server:

  • mlapi
  • mirror
  • photon fusion
  • photon bolt (legacy)
#
  • custom stuff
#

They all have their specifics...

#

But storing whatever is the server current state in a DB, is not really different

#

no matter which one you choose

ancient lantern
#

But if I'm relying on Photon to host (or using the standalone Photon instance) how can I have the server save data? If it's possible at all. I only want clients to connect to it, they save no data, it all comes from the server.

gleaming prawn
#

the differences between these will be about the NETCODE features they offer out of the box

#

But if I'm relying on Photon to host (or using the standalone Photon instance)
Please, be clear here...

#

You mean you are running a custom photon server + Photon Realtime or PUN2?

#

Notice I'm not even recommending these anymore (I'm one of the lead client SDK engineers at Photon)

#

PUN is a legacy product, and if this is a new project you should consider Fusion instead...

#

You can download and develop for free, and it offers the same type of CCU plans as PUN/Realtime

#

If you are considering go with one of our products, I strongly recommend you try Fusion, not pun

ancient lantern
#

I was indeed referring to PUN2. Also I would like something free, at least during development and before release (dunno if Fusion is free.) But the question remains, how to get any Photon server to connect to a database. Is the code modifiable in the standalone instance, and if it is, why is there a 100 player limit, unless that's not applicable to Fusion.

shut yarrow
#

Regardless of what type of framework you use (except relay based ones) your server is a standalone application running on a machine, and that machine can run any kind of software you desire. Then it's a matter of accessing the database API from your server application to get data from it

#

With relays you have little to no control of the server it runs on so that's why it's not a real great option for storing state

#

In almost any other case you do have access to the underlying machine and can run whatever you need

ancient lantern
#

I got really excited there, I thought, "yes. A solution. Finally my hair can stay in my head" and now I have more to look into with Photon. xD
Also with Photon PUN Cloud, the server isn't hosted by me at all, it's controlled by Photon and the rooms recycle by what I've read so there's no option of any persistence.

shut yarrow
#

My server runs on linux, it allows me to install any software I need and I can run any dotnet code of my choice

#

PUN is a bad choice anyway cause it doesn't scale with many players in a room, which is what you want right

#

And it's relay based

ancient lantern
#

I was under the impression by the "up to 50k players" on the site that that could be in a single room, but I could be wrong-

olive vessel
#

Not if they're all GameObjects

shut yarrow
#

You need something more than relays to get what you want

#

Something that gives more control over the network and the machine

gleaming prawn
#

And Fusion by default is client/server with full server authority (with client side prediction, snapshot interpolation, super fast delta-snapshots or eventual-consistency, lag compensation, etc)

#

With server being a Unity instance... room is used for:

  • punch-through connection signaling + relay fallback for client/server messages (so even if server is hosted by a player, there's no need to port forward)
  • handle host migration (being worked on)
shut yarrow
#

You opened up a rabbithole with your question ๐Ÿ˜„

ancient lantern
#

Kinda unrelated but I just found you on YouTube and am about to watch your 45 minute video on Fusion. xD
But in the end, I guess I have a plan now. I will look into Fusion and choose between that and Mirror. I think I'll build it in a single Unity project and add a build script. Unless someone here wants to teach me about MLAPI. Lol.

shut yarrow
#

I've seen people talk a lot about MLAPI this past week but none seem to know how it works yet ๐Ÿ˜›

ancient lantern
#

I mean. It's only been in development for how long now? Lol. It's pretty good compared to Mirror, if everything actually worked.

#

Or if there was better documentation.

shut yarrow
#

I've given up trying all these frameworks, they have a lot to offer but quite some time is needed to figure out how they work

#

In my case it was less work to make my own dedicated framework to get the things done I see as important

ancient lantern
#

Yeah, in the future I'm definitely going to have to spin my own. But that's for later me to deal with. For now I'm just trying to get some base ready for release.

shut yarrow
#

Granted that I've spent some time researching otherwise I would not even consider this

gleaming prawn
#

my piece of advert: neither mirror nor mlapi have anything close to: tick-accurate simulation, fast delta-snapshots, snapshot interpolation, client side prediction or lag compensation... (which are built in features in fusion)

#

You'd have to write all this yourself, and these are not simple...;)

shut yarrow
#

Yeah total pain in the back

gleaming prawn
#

not to mention other things like constant GC allocations and performance...

#

BUT

#

You should always try and choose what you think it's best for you

ancient lantern
#

Even lag correction on its own is a pain while still making sure they don't teleport across the map, I know this due to TypeScript not having any great modules for that and my other game. Lol.

shut yarrow
#

My framework does none of that except interpolation. My biggest pains were ease of sending data and low memory consumption

#

Anything else I can build on top if needed

verbal lodge
ancient lantern
#

Code examples were a huge problem. They are very basic, and in some cases, non-existent.

#

Also there were some problems I had with things like imports and using attributes. When trying to use a Client attribute for instance, I couldn't find what to import or what class to use for it.

verbal lodge
#

Code samples are a fair point, there is definitely a lot of improvements which we can make there. If you have a specific page let me know and I can take a look at adding a sample. Regarding namespaces that will be much simpler starting from the next version where everything will be under Unity.Netcode.

ancient lantern
#

Thank you. I honestly really value someone that approaches people that could give feedback on things, and I really do have great hopes for MLAPI. :)

#

Anyways, thank you all for your help. I swear, you've saved me days of messing around with methods that would probably never work. If there's anything I might be able to do in return, give me a DM or something.

gleaming prawn
#

yw

#

just keep being part of the community. Learn what you can and assist others when you have good advice to give.

ancient lantern
#

I've already been peeking at the other support channels waiting for something I can answer to. xD

valid totem
#

Hi, im using MLAPI and really overwhelmed on how to create a P2P game (that also supports singleplayer) efficiently, should I have two states for my script? Say for example: my Bullet.cs script would have network functionality like: "if hit, explode, send to clients that it exploded", but if its singleplayer it should only be "if hit, explode"

#

Currently right now I have a game that works with a very large asterisk as I keep getting these weird desync issues and the entire game breaks and the server doesnt do what it shoud lol

#

but thats another issue for another time haha

ancient lantern
#

I think what you'll need is an if statement checking IsConnectedClient.

valid totem
#

Well yes im aware of how to check if i am in a multiplayer game, but im not too sure on the actual therory of it, should I make two states in my code where its like such:

if server 
  do this shit

if client
  do this shit

if !client && !server
  do this shti but singleplayer
#

because I feel like i am overcomplicating it doing so

#

but this is my first attempt at a networked game so this could just be me learning and doubting myself

fickle geode
#

I choose a different approach: i have a damage script that has a "multiplier" value, i set that multiplier to 0 for network clients but to 1 for the server, then the server just directly dictates/sets the damage value for each player

#

so no damage is being applied on clients by themselfs, only the server sets the damage for the client, then you don't have to worry about networking at all in the damage script

#

you also avoid desyncs as the server is the one true source of how much damage/exploded a player is

verbal lodge
valid totem
#

thats very helpful, thank you all!

valid totem
fickle geode
#

so in my case I run all the clients as i would singleplayer, then there's a script that broadcast the state of the server (one of the clients that is hosting) to all the others and override any client differences

#

so basically as long as the input of all the players is reasonably fast, the simulation stays in sync, but yes dealing with lag in multiplayer is very difficult

ancient lantern
#

.>

fickle geode
#

spam ๐Ÿ˜› ?

valid totem
#

(like W, A, S, D)

#

but with Networked Transforms in MLAPI Im not sure if thats what I should do

#

Right now what im doing is making the player move his own player gameobject on his client, fully client based non server authorative

#

but obviously that leaves a large door open to cheating lol

fickle geode
#

hehe yeah for me that decision was not really an issue, as i'll be happy if there's enough players for it to even begin to attract cheaters. I was planning to do a big post about my custom UDP networking code / scripts setup for a sort of code review, just FYI i'm definitely no expert on the matter, so take my advice with a grain of salt

valid totem
#

I appreciate your insight nonetheless ๐Ÿ˜„

#

Is that similar to what you do though?

#

Player movement on the client?

#

and then have the player decide where he is rather than the server?

fickle geode
#

no for me the clients simulate physics combined with the current realtime inputs, then the inputs are send to the server, the server then broadcasts the input to all the players (excluding the sender ofcourse), then every 0,5 seconds there is a "keyframe" where the server broadcasts all the transformations and hp for all players, forcing a big sync up. With low lag those sync ups are hardly noticeable, with larger pings, you will see some players "jump". My next step is to fix up that jump by adding interpolation (slowly nudge the player to the server reported position over multiple frames) and add a tolerance (will players even notice that guy 50m away being off the real position by 1m). It only needs to be as accurate as the player needs it to be.

valid totem
#

Thank you for the detailed explaination ๐Ÿ™‚

sage agate
#

i used animation rigging on my character to hold the weapon and equip and recoil
the whole character was fully setup and then i made it a prefab
and then set up photon

but when photon instantiate the player
the whole thing is messed up
and then animation rigging isnt working
without Photon it was a perfect Player Character
but it doent seem to be good with photon
anyone know why is that?

wicked barn
#

im adding multiplayer to my game and whenever i build the game and my friends starts up the game it says that weve both joined a room but we dont see each other

heady stump
#

Are you telling all clients that a position has been changed when you move?

wicked barn
#

yeah i watched a tutorial mine didnt work but his did

heady stump
#

I'd doublecheck ur code then, its easy to miss small things that break everything

#

or if you want, you can start adding logs to the calls ur not getting to pinpoint the issue, for example in the server; log position update call, and then log the call handler in the client where you update positions in the client

wicked barn
#

well when i start the game up like we just not there can i see how many servers are available

#

ok @heady stump i watched the tutorial i used and when ever someone else starts the game up it says A new player joined the room

#

but theres no one there

sterile turret
normal dust
#

If I call a serverRpc and in this I do something, only the server will do it right? No client will do anything here?

austere yacht
#

yes, but if the server is a host, the host-client will, since it is also a server

valid totem
#

Hi, how would you sent a message to a specific client using MLAPI?

austere yacht
unreal sentinel
#

My MLAPI needs are different I'm trying to figure out object visibility. If I have instantiated objects can I hide those objects from the local host in the same way that connected clients can be denied getting a synced copy of it with a CheckObjectVisibility function call? My local host client seems to see everything.

#

Is it nessary to not instantiate any rendering objects on the host system except the ones I explicity want them to see?

#

or could I simply set them inactive without this interfering with what another client sees?

austere yacht
granite yew
#

Ummm I made this targeting system for my Among Us game but u end up targeting urself (with the ability) (I am using Photon btw)```cs
Player FindClosestPlayer()
{
float DistanceFromNearestPlayer = Mathf.Infinity;
Player closetsPlayer = null;
Player[] allPlayers = GameObject.FindObjectsOfType<Player>();

    foreach(Player currentPlayer in allPlayers)
    {
        float DistanceFromPlayer = (currentPlayer.transform.position - this.transform.position).sqrMagnitude;
        if (DistanceFromPlayer < DistanceFromNearestPlayer)
        {
            DistanceFromNearestPlayer = DistanceFromPlayer;
            closetsPlayer = currentPlayer;
            Target = currentPlayer;
        }
    }
    Debug.Log(Target.Name.text);
    return closetsPlayer;
}
olive vessel
#

Well, you need a check inside the foreach loop, if currentPlayer is localPlayer?, continue;

#

Idk how Photon lets you check if this is the local player

granite yew
#

ty

sage agate
#

i used animation rigging on my character to hold the weapon and equip and recoil
the whole character was fully setup and then i made it a prefab
and then set up photon

but when photon instantiate the player
the whole thing is messed up
and then animation rigging isnt working
without Photon it was a perfect Player Character
but it doent seem to be good with photon
anyone know why is that?

#

please ping me when someone responds

valid totem
#

Why are so many of the links to the MLAPI docs broken?

verbal lodge
#

Which links?

valid totem
#

A lot of the google links are dead pages and ~~ the replacement pages that I find using the search bar dont contain the stuff on the google preview~~

verbal lodge
#

Oh that sounds like something in the SEO is broken ๐Ÿ˜–. I'll let the docs team know.

valid totem
#

thanks! helping everyone!

granite yew
#

How can I modify this FindClosestPlayer function to find the SECOND most close player instead? ```cs
Player FindClosestPlayer()
{
float DistanceFromNearestPlayer = Mathf.Infinity;
Player closetsPlayer = null;
Player[] allPlayers = GameObject.FindObjectsOfType<Player>();

    foreach(Player currentPlayer in allPlayers)
    {
        float DistanceFromPlayer = (currentPlayer.transform.position - this.transform.position).sqrMagnitude;
        if (DistanceFromPlayer < DistanceFromNearestPlayer)
        {
            DistanceFromNearestPlayer = DistanceFromPlayer;
            closetsPlayer = currentPlayer;
            Target = currentPlayer;
        }
    }
    Debug.Log(Target.Name.text);
    return closetsPlayer;
}
shut yarrow
#

@granite yew I can cook something up for you

granite yew
#

yes plz

shut yarrow
#
int FindClosestPlayer(int excludeIndex = -1)
{
    float DistanceFromNearestPlayer = Mathf.Infinity;
    int closetsPlayerIndex = 0;
    Player[] allPlayers = GameObject.FindObjectsOfType<Player>();

    for(int i = 0; i < allPlayers.Length; i++)
    {    
        if(excludeIndex >= 0 && closestIndex)
            continue;

        if(i == localPlayer) //Fill in the index of the local player so you can skip it
            continue;

        float DistanceFromPlayer = (players[i].transform.position - this.transform.position).sqrMagnitude;
    
        if (DistanceFromPlayer < DistanceFromNearestPlayer)
        {
            DistanceFromNearestPlayer = DistanceFromPlayer;
            closetsPlayerIndex = i;
        }
    
    }

    return closetsPlayerIndex;
}

Player FindSecondClosestPlayer()
{
    int closestIndex = FindClosestPlayer();
    int secondClosestIndex = FindClosestPlayer(closestIndex);
    Player[] allPlayers = GameObject.FindObjectsOfType<Player>();
    return allPlayers[secondClosestIndex];
}
#

I haven't tested but hopefully it works like intended and you understand what I tried to do

#

I can give a little explanation

#

First find the closest player, store its index. Then go through all players again but ignore the closest player index, which should give you the second closest

granite yew
#

ummm I only want to get the second closets and not the first at all

#

but ok

shut yarrow
#

Yes you call FindSecondClosestPlayer and it'll give it to you

granite yew
#

ok

shut yarrow
#

You need to know who the closest is anyway to be able to tell who is the second closest

granite yew
#

alright

#

the closets is urself btw cuz of a bug so I improvise

shut yarrow
#

I made a mistake allow me to edit

valid totem
#
using System.Linq;
 
//get 3 closest characters (to referencePos)
var nClosest = myTransforms.OrderBy(t=>(t.position - referencePos).sqrMagnitude)
                           .Take(3)   //or use .FirstOrDefault();  if you need just one
                           .ToArray();
#

this will get the 3 closest

shut yarrow
#

I've edited it but maybe napkins approach is better

valid totem
#

ordered in closest, 2nd closest, 3rd closest iirc

granite yew
#

@valid totem does it only work with all 3?

valid totem
#

you can .Take() any amount

#

so .Take(1) would get the closest player

granite yew
#

or can I remove the 3rd player?

#

ah

valid totem
#

.Take(2) would get closest and second closest player

#

im not too well versed with Linq and OrderBy but this was a solution i used before

shut yarrow
#

Seems reasonable to me and definitely a lot simpler and cleaner than what I did

valid totem
#

uses n*log(n) time compelxity too so its great on preformance

granite yew
#

I will try both @shut yarrow son can u give me ur new code?

shut yarrow
#

I've edited the code so I would not spam too much here

#

I think napkins code works fine though, if possible use that

valid totem
#
using System.Linq;
 
//get 3 closest characters (to referencePos)
var nClosest = myTransforms.OrderBy(t=>(t.position - referencePos).sqrMagnitude)
                           .Skip(1)
                           .FirstOrDefault();
#

This is probably a better way, and will return you only 1, being the second (i havent actually tried it but give it a go!)

#

@granite yew

granite yew
#

ok

#

so I place this inside the FindClosestsPlayer function

valid totem
#

this is completely different from Swansons solution

granite yew
#

oh

valid totem
#

so you would have myTransforms which would be an array list of transforms

granite yew
#

would it be better with GameObjecgt[]?

valid totem
#

You can use GameObject[] but in the code instead of doing t.position you would do t.transform.position

#

but then at that point you might as well change it to .OrderBy(g=>(g.transform.position - referencePos)

#

so the variables make sense ๐Ÿ˜›

granite yew
#

but then I have to set the 2nd closets player to a GameObject reference called "Target"

granite yew
#

error CS1003: Syntax error, ',' expected

#

error CS1026: ) expected

shut yarrow
#

Can you show your code

granite yew
#

I am trying Swason's solution now so I can see which one is better

shut yarrow
#

If napkins solution works, definitely use his

#

Much less code so less chance of a bug and less clutter to look at

#

I can not guarantee I wrote bugfree code but I was hoping you at least could see the reasoning behind it

granite yew
#

doesnt work lol

valid totem
#

i meant a list not an array

granite yew
#

bruh

valid totem
#

List<Transform> myTransforms

shut yarrow
#

Yeah add all transforms except those of the local player since you don't want that one

granite yew
#

    Player FindClosestPlayer()
    {
             
          //get 3 closest characters (to referencePos)
          var nClosest = myTransforms.OrderBy(t=>(t.position - referencePos).sqrMagnitude)
                     .Skip(1)
                     .FirstOrDefault();
    }
#

@valid totem here is the code u gave me

valid totem
#

Yes now use that and adapt it to your code!

granite yew
#

uhhh its for finding second closets player

#

for multiplayer?

valid totem
#

Yes but its not networking related

granite yew
#

I am just dumb lol

valid totem
#

its just general game logic

granite yew
#

so the which value in ur code can I set it as the Target GameObject?

modern drift
#

if you dont understand his code

#

then learn how it works

#

dont blindly copy it

agile spade
#

hey, anyone here ever make a large scale MMO before? I got a successful kickstarter that reach goal + reach goal, and I ave a few hundred patreons.. my question is, on data management should i break my data up in as many tables as i realistically can or use larger master tables? for example, shipitems, playeritems, baseitems, or JUST an item table, atm I'm breaking the tabble down but, with 400 users (not even that many, I got a lot of my tables at like 14,000 rows and im wondering if i should break the tables down even more, and break this into TYPE tables, like, GameItemsSTORAGE, gameitemsInventory, gameitemshanger then, i can sib didive the tables again.

#

without deleting anything, just migrating what i already have

austere yacht
# agile spade hey, anyone here ever make a large scale MMO before? I got a successful kickstar...

if you have a relational data structure it makes sense to normalize it to a reasonable degree (3rd/4th normal form) to avoid most consistency issues... so you should not create as many tables as possible but aim at eliminating redundancy. Counterbalance that with the query/join performance, caching complexity, transaction guarantees and realtime-ness of the data you need. With many concurrent realtime users it might make sense to only push valuable data (like a players inventory) into persistent database and keep unimportant stuff like current world position in volatile memory with a background worker shoveling acceptably recent state into persistent storage... i'd expect volatile data structure then to be potentially very different from persistent storage and not at all table-based

agile spade
# austere yacht if you have a relational data structure it makes sense to normalize it to a reas...

i have currrency transactions, run through thier own http terminal and table. I have 3 main DB that just share the same playfab ID, one is for the irl currency and premium status/expire dates, and then 2nd is for skills exclusively and their training times. mongoDB, and the 3rd db is for items using google and AWS Aurora. my logic behind this is I can remove dependencies and the more secure stuff can be written slower (i just wanna make sure it can get accidently deleted) so, the databases go with authentication/validation gates. obviously anything relating to irl money has the most, anything with skills(some take 90 days to train at max level) has the 2nd most, and then items and locations change the most frequently so, i just want fast write/load times. if that makes sense

agile spade
agile spade
#

so, thing like currency only need a row per user but, some tables need to be made for currency convesrion using some of googles currency converters and build-in purchase stamping

#

those tables are hidden to me, but, they show up in bank statements

#

so, i dont care about seeing it now.

#

my primary question is about my 3rd/least secure DB

#

cause this will be updating and loading info on start up, and when the client DB attached to the network manger pings a new save on the server

#

and i want itteration to be fast.

austere yacht
#

you mean design iteration?

agile spade
#

if i can get it fast enough, ill just use async on an invisible load scene. for saves

#

but, atm, i dont know what is faster loading on the 3rd database structure

#

atm, its like 10 secondsish

#

but again, its only 400 users

austere yacht
#

does the save data relate to anything or is it just a blob of data that gets read back into memory when a player joins?

agile spade
#

load is structured.

#

it preloads all the assets related to the player at load

#

so, that way, when the player enters their space station

austere yacht
#

yes, but the data that drives it... does it have to be destructured outside that one load-process?

agile spade
#

it can grab all the scriptable object under that locations id

#

i think i get what ur asking, as it loads, its matches values on a new object, instantiates that object on a list ob objets under that type

#

then in game load

austere yacht
#

yes

agile spade
#

only looks at the lists that are relevent to itself

austere yacht
#

if you don't need structured data (strutured as in it has a schema that other processes will need to understand)... you can just MessagePack the whole thing into a byte[]

#

but that ofc prevents any kind of data migration (kinda)

agile spade
#

i was looking at this,

#

and he says dont use bytes

#

and gives some reasons why in his opinion its bad practice.

#

so, that why i build my client side this way.

#

watch it about a month ago

#

and was gonna go the binary route

#

but, hes like "no, if this happens at scale, or you wanna change a db value you gotta reload an entire patch

#

and its get super annoying for users

#

when you need to have a server downime and a new patch to download nearly everyday.

agile spade
#

ill have a better idea if this was the right move.

austere yacht
#

overall... the more structure your data has, the easier it will be to migrate things... A document store (like MongoDB), just from its design idea, is terrible (slow, complex) at querying structured data.

jolly wadi
#

Does anyone know how I can acces the player count of a session in fusion or how i can join a session ๐Ÿค”

valid totem
#

Hi, working on getting smooth interpolation in my game, I saw the wiki and it said that the Boss Room example used two gameobjects, a visual, and a literal (colliders+logic), Do they seperate them into two distinct gameobjects? or is it a parent hierarchy? eg, PlayerLiteral>PlayerGFX, then the PlayerGFX would set its own position based on the smoothing? am I understanding it correctly?
https://docs-multiplayer.unity3d.com/docs/learn/clientside_interpolation/index.html#boss-room-example

#

Should it look like the first image or the second?

sage agate
#

the problem is happening when i instantiate the player with Photon , thats why i am posting this here
i used animation rigging for my character
and then i animated the rig layer weights to make the player do stuff
but when i instantiate the player with Photon, the instantiated plyer dosn't change the rig layer weights when it should
can anyone help me fix this
please ping me if anyone responds

cerulean sorrel
#

oh, nevermind, after reading some more, it looks like the second one is right, and it just has a parent object assigned.

#

besides, if you have it transform parented, it can't "smooth the movement" towards the other object.

#

since it will just jump to the position of it's parent when it receives are server side position update.

valid totem
#

besides, if you have it transform parented, it can't "smooth the movement" towards the other object.

#

because this it cant be 2nd option?

cerulean sorrel
#

No, they could be siblings though, but the ClientCharacterVisualization.cs would have a public gameobject parent; and you would assign that with the "server position object" and every frame lerp towards with with the GFX object.

valid totem
#

Hm

#

An idea is to unparent as soon as its spawned

cerulean sorrel
#

I may have said it confusingly, sorry.
Basically if you have like

player ->
serverPositionObj
clientGfxObj

and the serverpositionobj is updated from the server, while the clientGFXobj every frame is lerping it towards the serverposition obj, it will smooth it.

valid totem
#

That is very helpful

cerulean sorrel
#

sure, or you could make the parent object a network object, but have the networkposition component on the "child" one

#

and the player object itself would just stay at 0,0,0 forever, I don't know if that would cause problems, but yeah

valid totem
#

Just a little annoying that I would need to have two prefabs for each object lol

cerulean sorrel
#

100%

valid totem
#

(one literal one graphical)

#

Trying to figure out if there is a better way other than (it works but its not great) haha

cerulean sorrel
#

The other option, that "may" work, is if instead, you grab the position on when the network updates it, and store it until the next position update, calculate the offset tothe previous GFX position and then lerp that offset to 0

valid totem
#

I appreciate your input and will absolutely try it

cerulean sorrel
#

which would allow you to have the obj structure like
player ->
clientGFXobj

and the clientGFXobj every frame is set (locally) to the lerped offset

#

though TBH, I dunno if that will work, and I don't know how hard it is to capture the network var update (I don't remember the specifics, but I think you can "observe" the changes somehow).

#

Yeah, np, hope it helps.

#

you'd of course have to do the same with with rot, but I think you get the general idea (basically what they do in boss room there, but changing it to update the GFX objs local position/rot to an offset that lerps to 0, so that it's always trying to match parent).

#

That actually helps me a bit, and maybe I'll build a small utility class that does that automatically, since that's one of the problems I had when I did some of the networking stuff lol, so thanks for making me think it through, weird how doing it for someone else seems easier to think through than when I'm deep in the code.

mortal horizon
gray pond
round reef
#

Hi, I making a 3D multiplayer exploration-survival game and I want to be able to save world data( where players built their houses, and all that stuff) Here is what I'm thinking: a player creates a game and the world is being downloaded on their pc. When a player connects he gets that data. If a player is building a house the other players will see him placing all the house parts. Is there any way I can make that for free(using photon networking)

gleaming prawn
#

Hi, there actually 3 different parts to your question:

  • what netcode to use (for free). From photon, I'd suggest Fusion, as it is the right solution for a more complex survival game. And just like PUN, you can have 20ccu free for development. You could also use MLAPI or Mirror, but to actually have the player communicating without running (paid) dedicated servers, you need to look for a punch-through solution (that to be complete needs a relay fallback - not sure if there are free ones). Maybe adapters using Steam network do this.
  • for persisting the game state between sessions, this is your job... you need to serialize your game state, and develop a way to re-initialize it... Not really something you will get off-the-shelf.
  • And, to STORE this somewhere (for free) you will either just store locally on the player's machine (so he could restart his server - like Valheim players do)... If you want to store online, I don't know free services for this (that are actually appropriate).
wary gull
silk helm
#

Hey guys, so I'm getting this error and im unsure why

#

My Code

patent fog
#

I don't use Photon but my guess would be that it doesn't know how to serialize a Vector3 by default. You'll have the same issue with the Quaternion I think.

#

I would check the docs to see if you can provide a custom serializer for any class. In last resort I would send each component of the vector separately

silk helm
#

I was following this tutorial for this

patent fog
#

I see, looks like you can yeah

#

Not sure why you would receive an int instead of Vector3 ๐Ÿคทโ€โ™‚๏ธ

sterile gulch
#

how can one do a certain action if client's attempt to connect is outgoing? (mlapi)

#

as in, if you try to connect continuously with no success, just stop the search for hosts

#

try statement doesn't work since there are no errors

vestal python
#
private GameSoundScript soundScript;
private Vector3 currentPos;
private Text debugText;

public override void OnStartClient{
base.OnStartClient();

if(!hasAuthority) return;

soundScript = GameObject.Find("Game Sound").GetComponent<GameSoundScript>();

debugText = GameObject.Find("Debug Text").GetComponent<Text>();
}

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

currentPos = transform.position;

if(!soundScript.soundIsPlaying){
       foreach(var item in soundScript.DictionaryTest){
                    debugText.text = "Player pos: " + currentPos;
}
}
}

I am using Mirror. When I set the text in the if clause, it works normally but when I set the text in the foreach loop, the text appears only on the Host screen, not the Client screen.
Can someone help me please?

heady stump
#

It seems to me that you're checking if its the server with !hasAuthority

#

So, if its not the server, dont do any of the code below

#

If I remember correctly from my short time with Mirror, that is how it works

idle seal
#

With Photon can i create a room as soon as the client joins the lobby?

vestal python
idle seal
#

because i cant get it to work.

heady stump
#

Your question is quite broad, but yea im pretty sure u can do that

#

Never worked with Photon but that seems pretty basic

shadow spoke
#

What you pasted is literally short-circuiting itself on non-server/non-host/non-authority things

#

Which means of course it won't display.

mint matrix
#

Hey guys little qeustion i made a multiplayer game via Photon
But i want now to try it via server based that i cna host on my own so any good tips for tutorials
Or a better networking sollutions?

gleaming prawn
shadow spoke
#

There's a few free ones, and of course, paid ones like Fusion. Take a look at each one before considering which one to program with.

#

Fusion is a good paid choice. Free ones include Mirror, Unity's own stuff, MLAPI, etc.

#

Just do your own research and dabble around with each candidate before you settle

mint matrix
shadow spoke
#

Define "makes a world"

#

How is that achieved?

mint matrix
#

he sort of host his own server

#

i mean like minecraft survivial for example

#

and poeple can join you from your pc

#

becaus i know this is how scrap mechanic does it but how
LIke i make a survival world and other poeple from other wifi can join me but its not running on a server

shadow spoke
#

Of course

#

Mirror can do that, MLAPI, etc

#

For example, you'd start host mode, then you give your friend an IP address and port, they punch that in and off you go

mint matrix
#

so pretty much every sollution can do that?

shadow spoke
#

Implementation varies but yeah, most (I say most, not all), support client hosted games

#

Where one client is godmode over everything and the rest are just normal clients

mint matrix
#

but in scrap mechanic you just invite your friends over steam and without an ip is this also possible?

shadow spoke
#

Yes, you can do that

verbal lodge
shadow spoke
#

Mirror for example has the Steam transport which harnesses Steamworks

mint matrix
#

oke

#

is their maby a good tutorial on it can be payd?

shadow spoke
#

Tutorial for what?

#

If you don't want to do port forwarding, you could for example, use again Mirror but with a relay for example

mint matrix
#

to do make that system

shadow spoke
#

If you want your own minecraft-like stuff, I'd probably point you to uVOXL which I believe is made in the style of Minecraft

mint matrix
#

minecraft was just an example

#

but thats sort of the way i am choosing

shadow spoke
#

Well, if you're completely green to networking, I'd suggest making your game work as a single player prototype first

mint matrix
#

oke

shadow spoke
#

then integrate multiplayer in later prototypes

#

Reason I say this is because some ideas and whatnot may encounter problems being networked

mint matrix
#

i made an fps with photon so i am not completly new to multiplayer

shadow spoke
#

Sure, but making a minecraft clone is completely different than a shooter

mint matrix
#

yea

normal dust
#

Using MLAPI. Anyone have a good tutorial on getting this set up?

"Host your game locally and open ports in your router. It should work just like over LAN you just have to connect to the public IP itself. Make sure to open UDP on the router."

indigo thicket
#

guys how does MLAPI handle spawning objects in a very different location with many players? Like in a survival or open world, where two players far apart have different objects spawned, and only the server has to handle all the objects simultaneously, while every client spawns only the nearby objects

normal dust
#

@indigo thicket I've done pretty much everything in my open world game for multiplayer except enemies. But I figure I just use .spawn() when players get close and .despawn() when no player is nearby.

regal delta
#

Opening up ports without knowing much about networking is asking to get hacked

normal dust
#

oh, 2nd device has a different ip address? thought they all have the same using the same router, ok

#

I also read I can do a relay with Steam since its a Steam game. So maybe I'll just wait to do it this way. Opening up ports sounds dangerous.

regal delta
#

The router hands out IP addresses to all devices on it's network. So your phone has a different one that your PC. If you got a game running on 2 devices on the same network with MLAPI running on both, you can get a local game running on both devices

#

Yeah relay would be a better alternative for multiplayer through the web, even if it's slower. Eventually you'll learn about networking and servers and stuff and might get the itch to build out a server to host games for your friends that's super performant. But you'll also need great internet

normal dust
#

its not a FPS so slower is fine.

wind citrus
#

Hey all, does anyone know why only the last joined player is the local player (IsLocalPlayer)?

#

Im using MLAPI

#

And im checking for IsLocalPlayer in the update of a NetworkBehaviour script

#

when i join with multiple players, only 1 person (localplayer) can actually get in the if check.

modern drift
#

what is frog?

#

where is it assigned

wind citrus
#

Frog is the actual movement handler, its another script on the same object. ill send some screenshots

#

also the object the scripts are on have networkobject, networktransform and networkanimator

#

Can there only be 1 local player on one machine?

normal dust
#

@wind citrusHey, the Rpc is called on the next update so if you are sending inputField.text in the Rpc then right after change to "" it will just send "" because Rpc is done after the update.

wind citrus
#

the thing is, it doesnt even send. when i press enter to send, it simply does nothing

normal dust
#

ok

wind citrus
#

ive debugged it and it never gets to the input check

normal dust
#

I haven't used isLocalPlayer at all.

#

I always use isOwner in all my multiplayer stuff

#

So maybe this might help, for each player what I did was activate only the player that is yours with a bool as true. So I didn't have to use isLocalPlayer.

wind citrus
#

i just tried it with isowner but what it does is (same as localplayer), when i host my game and join myself with a build client only the client can talk (hes the localplayer) then if i join on a 3rd client, that 3rd client is the localplayer

normal dust
#

And this is prob bad but it works. I search for all players and the newest player is always the last one found so I just activate that one as yours. Because new objects in hierarchy is placed at the bot so it finds it last in the search.

wind citrus
#

how did you "activate" it?

indigo thicket
normal dust
#

@indigo thicket damn this is tough. cause my next thought was to check the distance of other players, if its just you then don't .spawn() it, just instantiate it in as normal. but then if there is 2 players there and 2 players elsewhere then all players get it. idk man ><

indigo thicket
#

if I instantiate as normal, the server can't process it :\

normal dust
#

well yea, thats the point if your the only person nearby

indigo thicket
#

Well the server should be the one to handle something like spawning objects, getting them or handling enemies, for very basic cheat control

#

not really important in my game

#

but still weird to let the client simulate everything, perhaps it's also a problem if a player get close to another and has to spawn the local objects

normal dust
#

the other thought and idk if this works. can you disable on the client side, the networkAnim and networkTrans?

#

so your not sending info over everytime?

indigo thicket
#

I thought that too, but idk

#

I could create a custom function that spawns an obejct only for some clients, and the other clients "despawn" it

#

if it works

normal dust
#

I have done everything but the enemies in my open world game. so this is good to think about. cuz i have to do the same thing ><

indigo thicket
#

btw, have you sent big moles of data to a client? Like tiles of a map

normal dust
#

you wont be able to send much data at the same time with 1 rpc

#

you have to break it up into pieces

indigo thicket
#

I need to spawn 20x20 chunks while the player is moving

#

ok that's what I feared

normal dust
#

ok

indigo thicket
#

the rpc is blocking/has a maximum bytes?

normal dust
#

so i can help u with this

#

you are not gonna want every block 20x20 to be a networkobj, this is bad.

#

you are gonna want each player to hold this data by itself

indigo thicket
#

no no the tiles will be instantiated by the player

#

with his terrainmanager

normal dust
#

ok

indigo thicket
#

but I still has to send an array with id(s) that represents the tile

#

a matrix

normal dust
#

this is like MC, you move and it generates the world in chunks and you need other players to see this too?

indigo thicket
#

I've already encountered some problems sending custom classes via rpc, even serializable ones, but I think I was doing some mistakes since it was the first time using rpcs

indigo thicket
#

just a 20x20 matrix

#

of integers

normal dust
#

tbh, you can prob make an algorithm so you don't have to send the info over. Like my huge open world is generated with 1 map seed and so i only give the map seed to my clients.

indigo thicket
#

plus some objects like rocks, walls etc (that's why I asked how could I spawn things only for some clients)

normal dust
#

you have a random algorithm for new chunks?

indigo thicket
normal dust
#

cuz if its not random, u wont have to send much info, just where the chunk needs to go

indigo thicket
#

I could throw a seed and get the same random every time

#

this would block every tile-editing by the player, but i'm not currently planning to add it anyway so that's not a problem for now

normal dust
#

i keep an array of all my objects that are removed. and all build objects. with an objectID. well the build objects I need more info to send, like pos and rot.

#

so your talking about tile-editing should be fine

indigo thicket
#

Ok, thanks

#

hope the local spawn will work

#

and I'll definitely use a seed now

#

ty

normal dust
#

yw

#

@indigo thicket hey I was thinking about the enemies. I think what Valheim did was the enemies do .Spawn() but with networktransform and networkanimator turned off. Like I remember seeing the enemies far away in that game as statues. then when you moved in closer they started to animate and patrol.

solid sinew
#

Hey guys, I'm using Mirror Networking (similar to the old UNET framework). I'm trying to set up an FPS such that I have a server build running on a Microsoft EC2 instance and a WebGL client running on a Squarespace website with an insecure SSL certificate.

So far, I can connect to the server build when running the WebGL build locally, but when I try to connect from my website, I get "websockets failed to create secure connection".

I'm still in the middle of fiddling around & testing with the "ssl enabled" and "client uses wss" flags but what does this error mean and what is the correct way to set this up?

sage agate
#

When instantiating a player using Photon
Is it possible to just Instantiate a gameobject from the hierarchy instead of instantiating a prefab from the project files?

#

Please ping me when anyone responds

jolly wadi
sage agate
#

i have a Player controller, it holds the weapon
and i used animation rigging for it.
the animation rigging works perfect
but if i make the player into a prefab then the animation rigging no longer works
and it dosent work even after i unpack the prefab

jolly wadi
twin yoke
#

I'm having two problems with mlapi, if I add the approval check to my script handling connections the approval check is not ran even when assigned to the event. It appears this needs to be in a different script to run, I decided to attempt to code something much simpler and smaller than running off the server/client/shared scripts from boss room, so this is just going in a single script handling the StartHost() and StartClient() connections.

Secondly, when I connect as a host I will spawn the player object and be able to connect to server and run around, however when I switch scenes on a client (not host) I get an error scene switch can only be done by the server. I did have it where both players were running around in game on the server. however when trying to add new things it was getting broken and trying to deleting the player prefab of the client. Also, if I scene switch without mlapi and use unities normal scene manager it doesnt work properly. The client wont stay connected if I do a normal scene switch.

twin yoke
#

I notice the approval check is in the server part of the code, however there is no serverrpcs in that code in the boss room, what I was saying above is this is just using a script to handle the connections, and I'm not sure how those scripts without serverrpcs are all considered to run on the server

jolly wadi
#

just find the object in the scene you want to instantiate

#

the to normal instantiaition as such : Instantiate(gamobject, transform you want to instantiate it at); but put that in an rpc function to all other clients so it instantiates for all of them over the network ๐Ÿ™‚

sage agate
#

but wont we have to do it like PhotonNetwork.Instantiate to make it register as the player's?

jolly wadi
#

no if it is in an rpc it will happen over the network

#

So every player will do it on themselves

#

ultimately meaning the same as PhotonNetwork.Instantiate

sage agate
#

idk what an rpc function is

#

what is it?

jolly wadi
#

Hey guys , Iโ€™m using fusion and I am really confused how to join a session it should seem simple and lots of people seem to be able to make games with it but I can find anything ๐Ÿ˜“

thorny gale
#

Hey, which version of MLAPI is production ready

#

??

stiff ridge
verbal lodge
wind citrus
#

Does anyone know why only the last player that joins is seen as the localplayer? I've been looking for hours but i cant find out why..

#

this is what my networkmanager looks like

verbal lodge
#

I'm not sure what you mean by only the last player being seen as the localplayer.

wind citrus
#

Ok so when i host my game, the host is seen as the localplayer. Then when i join with another player, the new players IsLocalPlayer value is true and the old player's value is false

#

basically only the last player that joins reaches the actual Input.GetKeyDown check

indigo thicket
verbal lodge
# wind citrus

so on the player object owned by the host IsLocalPlayer becomes false as soon as you connect another player?

wind citrus
#

but whats weird is that in the movement script, i can walk on all players..

wind citrus
#

then the fourth is the only localplayer

verbal lodge
#

Yes that is to be expected. LocalPlayer means Player object which my specific client owns

wind citrus
#

yes thats what i thought aswell so i tested it with 2 other people (different pcs) and we joined. But still only the last player that joined could talk

verbal lodge
#

Are you sure that this is not related to your chat implementation. If movement works the IsLocalPlayer property should be working correctly.

wind citrus
#

ok so when i host the game andi m the only player this is the localPlayer value of the host. (Debug.log in movement script):

#

now when i join on a build:

verbal lodge
#

Yes this is to be expected

wind citrus
#

But they can both still walk which is really confusing me..

verbal lodge
#

On the host once you join there are now 2 player objects

  1. The player owned by the host where IsLocalPlayer is true on the host
  2. The player owned by the client where IsLocalPlayer is false on the host
wind citrus
#

yeah and for the build its the other way around right

#

for the client

#

there the client is the localplayer and the host is not

wind citrus
# wind citrus

But then its so much more confusing since in my chatting script i cant get past the first if check on the host now

#

Both scripts inherit from NetworkBehaviour and are on the same object which has NetworkObject, NetworkTransform and NetworkAnimator

verbal lodge
#

Try adding a debug log to see if that's really what's happening?

wind citrus
#

Hmm i added a debug log in the movement script which debugs the animator controller (This is so i can see which log belongs to who). but thats giving me a nullreference for the client

#

even though its not null on the client

#

the IsLocalPlayer did stay true on the host.. but he still cant chat

wind citrus
#

but then its really unclear to my why it doesnt get to the input check..

#

wait ... it does detect my input still

#

it just doesnt send

#

It doesnt get past the inputField.text.Length > 0 check

wind citrus
#

The Inputfield i use to write text in doesnt update when theres a client in the server

#

its always 0 and doesnt read the value i wrote in

sudden canopy
#

I'm trying to understand network stuff and Using MLAPI and read this line on the page 'The library cannot track objects that start in the scene.'
I want my scene to be designer friendly for when I do level design but some of the objects in the scene need to be able to move. Does this mean I have to rearrange and find a way to instantiate these scene objects?

verbal lodge
#

Where did you read that?

sudden canopy
verbal lodge
#

This is not true

#

Just the player object is handled differently, but you can have scene objects.

sudden canopy
#

so you can still have scene objects move without spawning them in a special way?

verbal lodge
#

Yes just put a NetworkObject + NetworkTransform on them, have them move on the server and they will be replicated.

sudden canopy
#

I think I might be better waiting a while I get a bug when trying to follow the tuitorial. it dosn't seem to like

using Unity.Netcode.Messaging;
using Unity.Netcode.NetworkVariable;

verbal lodge
#

I fixed this earlier this morning I think

#

Maybe I missed one

sudden canopy
#

The type or namespace name 'NetworkVariableVector3' could not be found

verbal lodge
#

Can you give me a link to the page you are using?

sudden canopy
verbal lodge
#

On my machine it shows updated for instance public NetworkVariable<Vector3> Position = new NetworkVariable<Vector3>();

#

Try ctrl + f5

sudden canopy
#

cool it's updated now. Thanks

verbal lodge
#

If you run into any other issues let me know. We just recently updated all our docs so it could very well be that a few things are still a bit shaky.

idle sonnet
#

so i need to get the result.Data[Key].Value.ToString(); to be returned to the function thats calling it i have this but it dont work: ```public string Get(string Key)
{

    var Requst = new GetUserDataRequest { };

    PlayFabClientAPI.GetUserData(Requst, result =>
    {
        return result.Data[Key].Value.ToString();
    }, error =>
    {
        Debug.Log(error.ErrorMessage);
    });
}```
granite yew
#

How do I make it so a function calls only if ur name is equal to a specific text in photon unity networking?

modern drift
granite yew
#

I already solved it lol

modern drift
#

oki

dreamy talon
#

How can I enter these -d parameters when I create a UnityWebRequest?

#

It didnโ€™t work when I input it as a string

#

UnityWebRequest uwr = UnityWebRequest.Get(url);

dreamy talon
#

Here is the other example, I donโ€™t know how to do either.

#

The first looks easier, I just need to be able to enter my authkey and target language as well as my string I want to translate

heady stump
# dreamy talon Here is the other example, I donโ€™t know how to do either.

It does not seem to be a data object that you need to create, so you basically just add the variables to your url;
"string myAuthKeyVariable = "abc123"; string text = "Hello,world"; string targetLang = "DE"; using (UnityWebRequest www = UnityWebRequest.Post($"https://api.deepl.com/v2/translate?auth_key={myAuthKeyVariable}&text={text}&target_lang={targetLang}")){ // handle coroutine } "

#

And here's how to create a post request with Unity

molten condor
#

I have a question: Im working on a project with multiple Player (using Mirror)
I want certain things be to the local player invisible like hats, nametag (...)
How can i make certain objects invisible to the local player?

molten condor
mortal horizon
#

@molten condor every network behavior class you inherit from allows you to access isLocalPlayer bool

molten condor
#

im sure its not if local player
object.invisible

mortal horizon
#

if(isLocalPlayer) yourGameObject.SetActive(false)

molten condor
#

is this right?

molten condor
#

so

#

If my game object is called BOX

#

i have to write BOX.SetActive (...)
and put the Script on the Game Object?

molten condor
mortal horizon
#

You can put it wherever you want as long as you can check if you're the local player and if you have a reference to the object you want to disable

molten condor
#

ok ill try

molten condor
#

cause in this reference there is a .gameObject. between the object and setactive

mortal horizon
#

Because camera is a component, and every component in unity has a reference to the gameObject its on. But if you're already accessing the gameobject directly you don't need to put it

molten condor
#

ok thank you

molten condor
mortal horizon
#

Anything attached to a gameobject is a component

#

Canvas and text are components

molten condor
mortal horizon
#

you mean its a child of the canvas?