#archived-networking

1 messages ยท Page 16 of 1

rapid carbon
#

It will be simpler but i think i should upgrade anyways 22 will be better then 21 anyways

#

Is it ?

candid ginkgo
#

I'm guessing so, afaik they added a bunch of new features but they're a bit too advanced for me so I can't really speak about it

rapid carbon
#

New things to learn as well

shrewd junco
#

If your project is already into development, I wouldnt upgrade

candid ginkgo
#

the only reason I suggested the new unity version is because I thought the ngo package version might be tied to it but if it's not don't bother

shrewd junco
#

If this is a new project, then might as well

rapid carbon
shrewd junco
#

Ah ye then doesnt matter

candid ginkgo
#

to upgrade you just download the new version and then change it in the unity hub

rapid carbon
#

Okk will be back after its done eating my 11gbs

candid ginkgo
#

but then to fix the problem you had with the input system I think you should try this

#

I don't think it's a problem with ngo's version since it wasn't giving you any errors

rapid carbon
#

Makes sense

#

I'll try

rapid carbon
#

I changed to new version now there is one new package netcode for entries do i use it? @candid ginkgo @shrewd junco

candid ginkgo
#

that depends on if you want to use ECS

#

but thats a whole other new system that you probably don't need for your player movement

rapid carbon
#

Great

rapid carbon
candid ginkgo
#

you still need to have a player transform component

#

not sure how it works exactly in the background but the docs mention that to use the networktransform component you need to have the sync transform checked in the networkobject component

#

either the clientnetworktransform or the networktransform

rapid carbon
#

Also now I am unable to drag my prefab to the network prefabs list why?

candid ginkgo
#

well the difference between client side and network transform is just who has priority over the movement

candid ginkgo
rapid carbon
#

Yes I just did that

#

Seems unnecessary tbh

candid ginkgo
#

yeah idk why it got changed between versions

rapid carbon
#

Well nvm- thanks tho

candid ginkgo
#

but that's for you to decide

rapid carbon
candid ginkgo
#

yeah there aren't that many I had to use the docs for most of what I did

rapid carbon
#

Okk I'll learn like this for now I'll when I get the hang of it then I'll try it

candid ginkgo
#

good luck, lmk if the script I gave you earlier helped or if it didn't change anything

rapid carbon
#

Okok tysm

#

@candid ginkgo ya so apparently I did not do anything just used the old script just checking and it's working lmao

candid ginkgo
#

lmao nice

rapid carbon
#

what is wrong?

sly pawn
#

I think the child network object won't be spawned over the network

candid ginkgo
#

you probably have a child object which has the networkObject component which I don't think is necessary if the parent has one

rapid carbon
#

Oh

#

Let me try

#

iit got fixed

#

but

#
            if(canShoot)
            {
                GameObject spawned = Instantiate(bullet,point.position,gun.transform.rotation * Quaternion.Euler(0, 0, -90));
                spawned.GetComponent<NetworkObject>().Spawn(true);
            }

but it is not spawning

candid ginkgo
#

are you spawning the bullet from the server ?

#

I'm pretty sure clients can't spawn objects

rapid carbon
#

but i m the host

candid ginkgo
#

oh mb

#

I guess just add prints evrywhere and see if it even goes in the if statement

rapid carbon
#

yes it goes that forsure

#

I don't get it

#

Do I need to call a client RPC?

candid ginkgo
#

I mean if anything it should be a server rpc since spawning is supposed to only be doable by the server

#

but idk if even the host doesn't spawn it it's weird

#

you did make your bullet a network object and added it to the prefab list right ?

rapid carbon
#

yes

candid ginkgo
#

maybe try making the 2 lines that spawn the bullet a server rpc just to be sure that the problem doesn't come from the fact that it might be called by a client

#

just as a way to clear that out

rapid carbon
#

but codemonkey did it like this only

candid ginkgo
#

oh ok

rapid carbon
#

also can a server rpc can be called through client

candid ginkgo
#

yeah that's the point

#

they're made so that client can run a bunch of code on the server

rapid carbon
#

ohk let me try adding a rpc calla

#

but codemonkey also showed client and server rpc shouldnt it be the same then

candid ginkgo
#

wdym the same ?

rapid carbon
#

what is the difference?

candid ginkgo
#

server rpcs are called by clients to run on the server and client rpcs are called by the server to run on the clients

rapid carbon
#

๐Ÿ˜ตโ€๐Ÿ’ซ

#

wont it be the same

candid ginkgo
#

no they are two different scenes technically

#

if I disable an object on my client it will still be enabled on the server

#

so if I wanted it to be sync'd I would disable it on my client and then send a server rpc that disables it on the server

rapid carbon
#

so if i call a client rpc will i be able to instanciate ?

#

to the server

candid ginkgo
#

no because a client rpc runs on code on a client

#

and spawning can only be done on the server

#

spawning is different from enabling/disabling/instantiating

rapid carbon
#

icic ig i kinda get it so can i call a server rpc while being a client will it work?

candid ginkgo
rapid carbon
#

y?

candid ginkgo
#

because since you were the host and the host it both a client and a server it should have worked anyway

rapid carbon
#

true

candid ginkgo
#

might as well try to make a server rpc to be 100% safe

#

you'll need it anyway if you want other clients to shoot

rapid carbon
#

icic

#

okk

#

let me

#

try adding a debug again

#

yes

#

:))))))))))))))))))))))))))))))

#

so

#

i m dumb

#

it was not being called

candid ginkgo
#

lmao

#

the power of debug.log

rapid carbon
#

yes lmao

#

let me just implement rpc now

#

is multiplay the only place where i can host it?

candid ginkgo
#

idk about that I'm using steam so it's peer to peer

real ingot
#

Yo how do I check if the player has connected to the server on StartClient?

empty night
real ingot
#

Oh wait

#

Ok I see

empty night
#

Can someone tell me how , when using netcode for gameobjects , I can spawn a player object for both host and client when its bult for standalone but for android only the host spawns a player object not the client

rapid carbon
#

GetComponent<NetworkObject>.spawn/despawn(true)

rapid carbon
#

Can someone suggest me a tutorial on how should I go about making a main menu and a lobbie list I can't find any on YouTube

zenith crescent
#
            if (_equippedSlot.childCount != 0)
            {
                ReturnEquippedItemToSlotServerRpc(_equippedSlotReturnLocation);
            }
            if (_slots[value] != null)
            {
                EquipItemFromSlotServerRpc(value);
            }
    }
    [ServerRpc]
    private void EquipItemFromSlotServerRpc(byte value, ServerRpcParams rpcParams = default)
    {   
        Inventory inv = NetworkManager.ConnectedClients[rpcParams.Receive.SenderClientId].PlayerObject.GetComponent<Inventory>();
        _slots[value].GetComponent<NetworkObject>().TrySetParent(inv._equippedSlot);  
        inv._equippedSlotReturnLocation = value;

    }
    [ServerRpc]
    private void ReturnEquippedItemToSlotServerRpc(byte value, ServerRpcParams rpcParams = default)
    {   
        Inventory inv = NetworkManager.ConnectedClients[rpcParams.Receive.SenderClientId].PlayerObject.GetComponent<Inventory>();
        inv._equippedSlot.GetChild(0).SetParent(inv._slots[value]);
    }``` how can i make other clients change or set a objects parent to a different player so if i set the parent of a item to the player i want other players to see the change how would i go about that im used to pun2 so im really lost
#

ik this setup would only inform the server but i cant find a way to let other clients see the change

#

using NGO

covert veldt
#

Hi I have a serverRpc that runs well and inside I had a function that only ran on client so I changed it to a serverRpc as well and now it doesn't run at all. It's on a NetworkBehavior with NetworkObject. Any ideas? ๐Ÿฅด

upbeat pine
#

what does [ObserversRpc] mean?

halcyon flame
#

If you call a function from the server it will always be ran as the server, unless it's a client rpc

#

It doesn't matter that your client can call a function, as it will be ran with the clients variables anyway (which are either server authoritive, or not present on the client)

toxic slate
#

hi guys! for more complicated player prefabs how would you go about netcode for it? ie. for my player movement code i'm using a finite state machine, and most netcode explanations say to just check for owner, which im not sure how to do in this case

real ingot
#

put that in the beginning of a method

#

that'll make sure to prevent any other clients interfering with other clients scripts

vivid viper
#

can someone help me with a netcode issue? willing to hop on a call and show them or just via dms

#

theres a problem with an item spawning thats meant to follow the player, yet it just either stays at the middle not registering for the other player, or just doesnt register

#

if u need more info dm me

real ingot
#

Anyone know how to check whenever a client has connected to a server?

empty night
#

OnClientConnected is a method call.. google searchit

empty night
real ingot
real ingot
empty night
#

No problem , you can ask chtgpt also for an example usage in unity using c#.

real ingot
empty night
shrewd junco
shrewd junco
empty night
#

Shows what you know guy , it can provide updated info for a lot of stuff. And its not used as a crutch but as a tutor..

empty night
shrewd junco
#

i dont care if you personally use it, just dont suggest others do especially for ngo. Its clear when code is written by AI, and its even worse when someone asks for help on code they didnt write or understand

empty night
#

That's what i use ai for explaining code to me and dissecting bugs

#

But i can also agree it doesn't always provide the best info. Like unity's new input system

candid ginkgo
#

I hope whatever Unity's AI project will be it'll include an AI that has been fed all the docs so it can give clear explanation and help with using recent systems

#

also nothing to do with that but anyone knows if there's a way to implement client side prediction for rigidbody movement without having to essentially rework the networkTransform component ?

shrewd junco
#

if the client is supposed to predict how it work running into another rigidbody.. im not sure there because im trying to solve the same issue and i hate it

candid ginkgo
#

but to implement basic transform synchronization did you have to remove the networkTransform component and make your own ?

#

cuz I don't see how it's possible to keep using it since it only let's you change the transform from the server

candid ginkgo
shrewd junco
candid ginkgo
#

yeah from what I read it seems pretty doable for character controllers but physics seem to be a lot harder to manage

#

I don't think I'll have to care too much about predicting player's pushing around stuff since the main reason I used a rigidbody was to be able to maintain the player's velocity when doing certain actions

candid ginkgo
#

like does having synchronize transform checked matter at all or is it only useful for the networkTransform components

shrewd junco
candid ginkgo
#

isn't that already the case when using NetworkRigidbodies since they are set to kinematic on clients ?

shrewd junco
shrewd junco
candid ginkgo
#

isn't there a way to temporarily make them not kinematic for your calculations ?

candid ginkgo
# shrewd junco yes, which is quite annoying for my game at least. I need players to push around...

I saw this video where the guy doesn't really go too much into details about how it works but in the comments he linked a github page where he explained how he implemented it : https://www.youtube.com/watch?v=G93XdHNjONQ&t=12s

I have been working on client side prediction for 2 whole months now, and i finally managed to get it to work smoothly

โ–ถ Play video
shrewd junco
#

my calculations will be pretty much every second, since my game is all physics based :p

shrewd junco
candid ginkgo
#

yeah fair enough

shrewd junco
#

doesnt matter as long as they dont make a mistake i mean

candid ginkgo
zenith crescent
#

is there a good solution to having a "Pickup" of an object currently u can only have one networkObject on a prefab so i have one on the root, and u cant have one on the hand to parent to, so u have to either like fake the position or something? does anyone know a good workaround or solution to parenting a networkobject to a transform

#

saw something abount parent constraint or spawning the hand and parenting it under the player on network spawn

#

using NGO

candid ginkgo
#

I never tried doing any pickup systems but if you look into the client driven sample I'm pretty sure it has a pickup system

#

it's client side but it might still be helpful

zenith crescent
#

alright ill check it out

candid ginkgo
zenith crescent
#

i beleive on this i just looked and it parents it to the transform so just the root not a nested object so apparently unity thinks this is the best solution!! there smart

simple bear
#

Does anyone here have experience with Photon Fusion? Do NetworkedObjects get destroyed when the network runner gets destroyed?
I have a NetworkSpawner object in a scene that gets destroyed when the network runner gets destroyed (i.e. when the host leaves). I want to stop it from getting destroyed. How do I do that?

vagrant garden
#

The only way is way a custom network prefab pool. But generally you want to have them destroyed when the networked session ends as they will no longer function properly without the runner.

vagrant garden
simple bear
vagrant garden
#

Fusion has built in host migration.

#

Which is the only proper way to implement this. It is much better than a manual implementation

simple bear
#

I am using that. But from tutorials I understand that I have to make connection tokens to assign each player with their in game players

#

In my case, cars

real ingot
#

Yo I'm kinda confused right now. I made a script where a ui enables and disables it self whenever a client triggers a collider. I didn't expect it to work cause I thought that I need to do some networking so that whenever a client triggers the collider it wouldn't enable or disable any other client's ui. But it seems like everything works fine. Why?

#

Oh wait I guess it makes sense. Without the networkObject or any code it won't send the changes to the server so it's all good

#

How do I despawn a collided object something like this?

#

I'm trying to despawn an object for everyone in the server

candid ginkgo
clear jolt
#

I think I'm facing something also related to the prediction issue? but it behaves strangely so I'm not sure which part should I improve.

clear jolt
#

The child components of a prefab is pretty leggy and was not sync as a whole unit in other client's view.

real ingot
#

I'm having issues with the serverRpc.

nocturne vapor
# real ingot I'm having issues with the serverRpc.

You can't pass a gameobject in a serverrpc, you can have a script on the gameobject which has a public destroyServerRpc function, which just despawns and destroys this.
This way you can call it from any client

real ingot
real ingot
#

can you even despawn an object that was manually added to the scene in the editor?

nocturne vapor
real ingot
cyan cobalt
#

topolgy

upbeat pine
#

Im trying to play my coop game with friendsusing hamachi

#

but it doesnt seem to work

#

the tutorials I saw use zerotier but it doesnt open for me

#

what should I do

nocturne vapor
radiant dome
#

Hi guys i am having this problem with Vivox,can you help me?

upbeat pine
#

or am I misinterpreting something

nocturne vapor
upbeat pine
nocturne vapor
#

yes

upbeat pine
#

thank you

real ingot
#

yo! How do I find the player GameObject of the owner in a gameobject that contains all the clients? In UNet there used to be a NetworkIdentity but in NGO there isn't. Any other way to do this?

upbeat pine
nocturne vapor
upbeat pine
#

?

nocturne vapor
#

yes and on your local network with another machine

upbeat pine
#

yes

#

it does

nocturne vapor
#

how do you try to connect via hamachi?

upbeat pine
nocturne vapor
upbeat pine
#

using fishnet

#

when connected to the same network

#

and thqat would work

nocturne vapor
#

I don't know about fishnet but no, you need to tell your game where to connect to. Have you every tried your game on different machines?
An ip address points you to another pc, you need to tell the game which pc the server is, if you only tested on your own machine it has a default value for hosting with localhost and the client will defaultly connect to that (atleast in most networking solutions, no clue of fishnet)
you need to change that and than the other person can join via the given hamachi ip adress

#

I always forget the reply thing @upbeat pine

upbeat pine
#

Ill try that thank you

nocturne vapor
#

no it sadly doesn't and if you ever want to release your game, this gets more complicated

#

I wrote a more detailed explanation of how to do it without IPs here
@upbeat pine

half anvil
#

how to spawn player at a given location in multiplayer in netcode

real ingot
# real ingot ?

Never mind I figured it out. I got the object that contains all the players in my script and did a foreach loop and looked for the player that is IsOwner = true

terse idol
#

Hi, between photon fusion and mirror. which one is better and why?

real ingot
untold imp
#

Hi, I'm trying to create shooting mechanic in my game. In short player spawn bullet locally then send rpc to other clients to spawn local version of bullet (bullet is not network object). As you can see on image it creates weird effect. I think it can be a problem with player position interpolation but I'm not sure. Do you have any idea how to fix it?

nocturne vapor
# untold imp

can you try how it looks when handling the spawning completly in the clientrpc?
so your playerWhoShoot variable would be used to determine to set data.damage and not to return

spring void
# untold imp Hi, I'm trying to create shooting mechanic in my game. In short player spawn bul...

You can slightly reduce the differences by checking out the latency and adjust the bullet position accordingly. E.g. if a player has 1s lag, then after spawning his bullets you should simulate how the projectile would behave during this time, moving it further and potentially hitting something.

Btw, the starting parameters should be calculated on the server, unless you want to give cheaters an opportunity to modify the app to spawn their bullets directly inside of an enemy.

untold imp
#

Player position is interpolated so it can create that weird effect

#

Without interpretation shooting is correct but player move looking terrible

#

You should first in update check for input and if player can shoot and then if yes use serverRpc to spawn bullet

#

In your code shooting script only run on server

split hedge
abstract copper
#

you are only showing part of the relevant code

#

you don't show where rotZ is set, which is very very relevant to the issue

#

also none of the previous messages in this channel have been about your issue lol, they were sent hours ago

abstract copper
#

yes, so in your current code, only the client knows what their rotZ variable is

#

the server does not know

split hedge
#

So it should become a networkvariable?

abstract copper
#

no

#

as a parameter

split hedge
#

I did use that method

#

That didnt work as well

abstract copper
#

you said it didn't work, but you need to show your attempt

split hedge
#

Okay 1 second

#

Now it works like this @abstract copper :
If I shoot with the client it does rotate (the bullet), but it'll always shoot from one point

abstract copper
#

notice what you are passing into the RPC function

#

and whether or not it makes any sense

split hedge
#

or frick

#

yeap

#

Thanks you helped !

upbeat pine
#

How do I make it so the player can see the bodies of other players in the game but can't seen his own?

forest pike
#

I'm currently trying to use unity netcode and I made a working multiplayer where I can play together with Host and Client on my own PC. But when I try to start a Host on my pc and then join with Client on a different PC in the same network it doesn't work and the Client can't find the Host somehow. Does someone know what is the issue here or where I can find something about this topic. Because I can't find anything useful regarding this in a forum. thanks

gray warren
#

Hi ๐Ÿ‘‹ , I'm returning to Unity after a while and couldn't figure out if UnityWebRequst (https://docs.unity3d.com/Manual/UnityWebRequest.html) is part of the Netcode package or is deprecated . Should I use C#'s HTTPClient for example? I need to make simple GET/POST/DELETE requests.

lean anchor
#

does the free version of photon fusion automatically "lock" servers if more than 100 players are in them?

vagrant garden
#

The free version of Photon Fusion only supports 20 CCU not 100

#

And yes it hard locks

gray warren
lean anchor
lean anchor
# vagrant garden Yes

great. is it 20 ccu per account or 20 ccu per project?
also when it says for non commercial use, if i dont add microtransactions to the game and make it free, is it allowed?

untold imp
#

you need to do port forwading on your network

#

or you can use unity relay

nocturne vapor
gray warren
vagrant garden
cloud kite
#

Anyone else has experienced this sync problem with players? The players are hovering on different highest on each client

spring crane
cloud kite
#

Got it thanks. I just unticked Interpolate on the Client Network Transform

mental pond
#

Is there someone who can help me with specified problem, I want to switch from Dedicated Server to Custom Server but I need Rigidbody, GameObject from API because I'm synchronizing Physical Object over network on server and sending position to clients. Is there solution for this? Hope you understand. I'm using LiteNetLib as Networking.

lean anchor
mental pond
#

offering 100 โ‚ฌ for help

#

DM me

naive yoke
#

Are there any audit tools out there to check for unity vulnerabilities? Cause i seen some videos where the user could mod the info at front end and gives them advantage during gameplay

vagrant garden
#

This depends on the networking solution you use. No tool can audit this, needs to be a human doing the test.

regal gull
#

Hey guys, I am trying to add the Flatbuffers library to my Unity project and I want to build for Android and iOS

#

In all the tutorials I've seen the library is in a .dll so I think that would only work with Windows right?

#

I am basically trying to serialize data in the Unity client and send it using sockets to a C++ server, and viceversa. Is Flatbuffers a good library for that? Or are there better options out there?

real ingot
#

Yo! How do I spawn objects? I tried to do something like this:[ServerRpc] public void SpawnObjectServerRpc() { GameObject weapon = Instantiate(weaponData.ItemData.weapon); weapon.transform.SetParent(weaponHolder); weapon.transform.localPosition = Vector3.zero; weapon.transform.localRotation = Quaternion.Euler(Vector3.zero); weapon.transform.localScale = Vector3.one; weapon.GetComponent<NetworkObject>().Spawn(); }
but it doesn't even call the method. I want so that whenever a client presses a key it'll spawn an object, but when I do that in the if statement where it checks if the client presses or no it gives me an error in play mode when I press the key that only the servers can spawn objects. Any help with this?

#

do I even need to do this in a ServerRpc?

mental pond
#

Can explain you in DM add me

real ingot
#

Can't you help me in here? I thought it'll be quick

mental pond
#

?? Im not talking to u bud ๐Ÿ˜‚

elder sorrel
#

Hey All I am working to make a WebGL build. I need to have a scene be hosted on a server that will have a landscape and few NPC zombies using a script able object to keep track of everything happening in the scene. The WebGL will be using the client scene and will have a character with a name and different customisations and than will load into the zombie infested scene to go kill some and spawn back to the previous scene being the space the character is in.

What kind of service should I use for a prototype build and only like a max of 10 people playing it.

untold imp
zenith crescent
#

    public void OnTransformParentChanged()
    { 
        if (transform.parent == null) 
            OnItemDropped();
        else 
            OnItemGrabbed(equipSlot.Value);
    }

    [ServerRpc(RequireOwnership = false)]
    public void SetEquipSlotServerRpc(ulong id, byte slot)
    {
        ItemTransform itemTransform = NetworkManager.SpawnManager.SpawnedObjects[id].transform.GetComponent<ItemTransform>();
        itemTransform.equipSlot.Value = slot;
        print("Setting value to " + slot);
    }```

```    private void RaycastToItem()
    {
        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out RaycastHit hit, 5, layerMask))
        {
            if (hit.transform.CompareTag("Item"))
            {
                for (byte i = 0; i < _handItems.Length; i++)
                {
                    if (_handItems[i] != null) continue;

                    if (hit.transform.TryGetComponent<NetworkObject>(out NetworkObject networkObject))
                    {
                        NetworkObjectReference reference = new NetworkObjectReference(networkObject);
                        networkObject.GetComponent<ItemTransform>().SetEquipSlotServerRpc(networkObject.NetworkObjectId, i);
                        PickupItemServerRpc(i, reference);
                        return;
                    }
                    else Debug.LogError("Failed To Get Component [NetworkObject] from Item");
                }

                Debug.LogError("Your Hands are Full!");
            }
        }
    }```

i have the top script that is called from the players inventory script however the host can call SetEquipSlotServerRpc (on the second script) and it works perfectly but when a client does it i get no errors the network variable equipSlot just doesnt change and i dont know why
tidal moat
#

Is there a way to get The ping of each player and display it using a TMP using Mirror and FIzzySteamworks?

real ingot
#

Hi! Any way to use NetworkVariables and assign a GameObject without getting the GameObject not supported error? I need to do that so that I could spawn objects through another script

sharp axle
nocturne vapor
nocturne vapor
# real ingot Don't need it

wasn't reading the original message, busy with stduying for exams and only replied to the ping
what you could do is having a gameobject manager which takes a prefab, gives it an id, which you can than use in a network variable, thats how I handle my item spawning

real ingot
#

I already did it

#

don't worry

#

I said I don't need it

#

I was kinda in a hurry so I phrased it like that. Sorry

obtuse token
#

Please guys, help me i need Head Motors based on IK, whos can help? Please.

#

With limit

south prairie
#

hey all, can anybody throw me a few info bits if Unity's new NetCode is worth migrating to? Ive been out a couple of years... So many people use alternative network solutions nowadays (like Mirror)....

nocturne vapor
nocturne vapor
#

That is good

real ingot
#

Anyone know why my TrySetParent doesn't parent the object?

#

If needed I can give more code

#

It spawns the object but it doesn't parent it. No errors either

#

the "weaponHolder" is the clients characher's hand. The hand doesn't have a networkObject, only the player prefab has it

nocturne vapor
real ingot
#

but I'm not sure if that works

nocturne vapor
#

And yea networkobject nestimg is only allowed in certain cases

real ingot
#

are you saying I shouldn't even spawn it, just instantiate the weapon and add client network transform or something?

#

by send rpc you mean send the thing that got instantiated and make other clients instantiate the weapon and let the client network transform do the job?

real ingot
nocturne vapor
#

But yea instantiate it not spawn it

real ingot
#

I'll see

real ingot
#

I have found another solution. Tbh there's quite a few solutions to it. I'll show what I did after I do it for anyone struggling with the same thing cause it seems to be a common thing

wraith violet
#

How would i sync one global variable with all clients? Iโ€™m having trouble with that

#

Like, if there was one variable for, letโ€™s just say, whoโ€™s turn it is

#

If i have two players, and player one takes their turn, player two doesnโ€™t get the message

untold imp
#

How can I create own interpolation script to networkTransform?

fading hazel
#

Anyone with some networking knowladge ?
anyone can help me with some basic Networking setup ? i got a basic setup for multiplayer game, i got a moving platform, but can seem to move the players without lag, and when using the Client authoretive movement it has lag, anyone up for a bit of help ?

wraith violet
fading hazel
#

im trying to do a moving platform that players can turn on when it turns on it moves (like a big car) host players behaves well but remote client dosnt move with the moving platform

wraith violet
#

can i get an example of using network variables as a global variable?

real ingot
# real ingot I have found another solution. Tbh there's quite a few solutions to it. I'll sho...

For anyone that has a problem with spawning a GameObject and parent it onto an object of a character some where deep e.g. Hand. Since you can't parent an object in a GameObject that doesn't have a NetworkObject component instead of putting the weapon or spell or something else in the root of the player prefab do this:

  • Make a new GameObject in the hierarchy create a new script and assign the script to the GameObject.
  • Call an Awake and inside the Awake do DontDestroyOnLoad(gameObject);.
  • Call a public serverRpc with RequireOwnership = false and serverRpcParams = default and call this script in another script where you want to equip a weapon, spell or whatever.
  • Inside the ServerRpc do this var clientId = serverRpcParams.Receive.SenderClientId; var client = NetworkManager.ConnectedClients[clientId];
  • Make a ClientRpc with parameters ulong playerObjectId somewhere in the same script and call it in the ServerRpc like this ClientRpc(client.PlayerObject.NetworkObjectId);
  • Inside the ClientRpc get the parent Transform and Instantiate the weapon/spell then parent it something like this transform.parent = theParent; and then set the position, rotation, scale if you need to (Make sure to do that after parenting the object)

This way every single client in the server will instantiate the weapon on you.

No problemo

#

If you are making a game where people can join whenever they want don't use this since the players that joins after the object instantiates it's not going to instantiate for the new player. You can maybe try doing something but the best way to do this would probably be simply placing instantiating the object in the player prefab root.

real ingot
#

I have a feeling that there's a way around it though. Like instantiating the weapon for the new player that joins. Maybe have a list that will contain the instantiated weapons and from that list the new player that joins will instantiate all the weapons from that list. I'll try to figure something out.

covert gull
#

Anyone know if Vivox works with non-Unity multiplayer netcode such as FishNet or Photon Fusion?

cosmic echo
#

Hello I'm currently working on a player selection system to allow players to view each other's names and stat values(HP/MP). I'm trying to use raycasting to detect player tag, but this only works properly for the client that is running the server.(which doesn't quite make sense to me..) For other clients, the detection field is way off the player model but is somewhat constant, it's as if there's an invisible box above the player model that can't be adjusted. I'm using Fishnet for networking.

Here's part of the relevant code.

    {
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            DeselectPlayer();
        }
        
        Ray ray = cam.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out RaycastHit hit))
        {
            if (hit.transform.CompareTag("Player"))
            {
                NetworkBehaviour clickedPlayer = hit.transform.GetComponent<NetworkBehaviour>();
                isHover = true;
                if (clickedPlayer != null && clickedPlayer != this && Input.GetKey(KeyCode.Mouse0))
                {
                    SelectPlayer(clickedPlayer);
                }
            }
            else
                isHover = false;
        }


        if (selectedPlayer != null)
        {
            UpdatePlayerInfo();
        }
    }

    public void SelectPlayer(NetworkBehaviour player)
    {
        if (selectedPlayer == player)
            return;

        selectedPlayer = player;
        UpdatePlayerInfo();
    }```
tacit wadi
#

Hello guys!!
I want to ask for a little help.
I'm currently making a small project about library management system.
The deadline for the project is really close and I'm stuck at networking.
I'm making a two projects for the system. One for library managing(Windows) and one for QR code scanner(Android).
The reason why I'm making a QR code scanner is I want to keep tracks of who enter or exit the library.
I got the idea of QR codes. I can scan a visitor's QR code and send it to unity and then to the database.
I used LAN connection with TCP. I tested it and it works really well.
The problem is I can't connect my android(Client) to my pc (Server).
I also can't connect from my friend's pc to my pc. It only works in the same device.
I searched for solutions for my problems, none of them works for me.
There is a interesting article which tell me that I need an access to my router and use port forwarding.
Is it true?I'm only using LAN. I saw some old games use this method. I don't think they need port forwarding or something like that.
One phone turn on hotspot and other player can join the game easily.
I will provide some of my codes. Please, help me.

#

I used this two scripts for connecting the projects. I got these from Unity forum.

#

I just have a few days before the deadline. Please, help me.

supple lodge
#

Particle system in netcode for gameobjects

Hello, im developing a realistic fps with multiplayer using netcode for gameobjects.
Im stuck at trying to get the muzzle flash effect to show for the other player, my particle system is attached to the gun and played with this function:

public void shoot_muzzleflash()
{
        muzzleFlash.Play();
        

}

and im activating this function in an animation with an event.
I tried this:

 
[ServerRpc]
    public void CmdStartParticles()
    {
        RpcStart_shoot_muzzleflash();
        shoot_muzzleflash();
    }

    [ClientRpc]
    public void RpcStart_shoot_muzzleflash()
    {
        shoot_muzzleflash();
    }

    public void shoot_muzzleflash()
    {
        muzzleFlash.Play();
        

    } |

but then i cant choose the CmdStartParticles() as an event in the animation

im experienced with unity but not with netcode, so sorry if this is a noob question

wraith violet
#

Iโ€™m not that good, but what if you just hooked up another function to the event, that just called cmd start particles

supple lodge
abstract copper
gleaming zenith
#

How are you supposed to parent and unparent Network Objects???

sharp axle
gleaming zenith
sharp axle
gleaming zenith
quiet ginkgo
#

Is SteamMatchmaking.RequestLobbyList blocked if you "spam" it by refreshing the list too often? It seems to be the case.
I just spammed it on purpose and it did not block me, so an error must be the cause.

median gale
#

Hello,
I am using PUN2 and Unity version 2021.3.16f1
I have a function called AddCoin(). This is called when the coin collides with the player. The purpose of AddCoin() is to add the amount of coin collected to the current amount of coin the user has.
It works great if the user collects one coin at a time. However, if the user happens to collect 2 coin at almost the same time, then only one coin gets added.
I included a debug log right before SetCustomProperties to see if the coin amount is correct, and the amount appears to be correct.
I read somewhere that SetCustomProperties takes time. Is there I can something I can do to make SetCustomProperties work if the player collides with 2 coins at the same time OR is there another approach I could try?
See Code.Png for AddCoin() implementation
See example.gif for the issue I'm describing. You can see the player collide with two types of coin, $5 and $25. Both coin got hit but the scoreboard only add $5.

median gale
median gale
# median gale I should mention I have a OnPlayerPropertiesUpdate() that sets the coin text in ...

Did a bit more debugging, it seems like when 2+ coins are collided with the player. Both would read the current amount of coins. For example, say I'm currently at $180, and then I collided with a $25 and a $5. My logic seems to be reading $180 +$25= $205 and then $180+$5=185.
[EDIT]
I placed some breakpoints at where SetCustomProperties is called and where OnPlayerUpdateProperty is called.

What I thought the logic was when colliding with the coin is. Say current amount is $180

  1. Collide with 1st Coin
  2. SetCustomProperties - add the 1st coin say it's $25
  3. OnPlayerPropertiesUpdate() - updates scoreboard - add 1st coin value to current amount. $180+ $25 =$205
  4. Collide with 2nd Coin
  5. SetCustomProperties - add the 2nd coin say it's $5
  6. OnPlayerPropertiesUpdate() - updates scoreboard - add 2nd coin value to current amount. $205 + $5 = $210
  7. Result is $210

What is actually happening

  1. Collide with 1st Coin
  2. SetCustomProperties - add the 1st coin say it's $25
  3. Collide with 2nd Coin
  4. SetCustomProperties - add the 2nd coin say it's $5
  5. OnPlayerPropertiesUpdate() - updates scoreboard - add 1st coin value to current amount $180 + $25 = $205
  6. OnPlayerPropertiesUpdate() - updates scoreboard - add 2nd coin value to current amount $180 + $5 = $185
  7. Result is $185

So it seems like there is a delay between SetCustomProperty and OnPlayerPropertiesUpdate()

half anvil
real ingot
gleaming zenith
#

I want to parent a NetWorkObject to a child of my Player Network Object but that doesnt work is their a workaround to parent NetWorkObjects to childs of your playter Network. sorry if this is worded weirdly lol

untold imp
#

Hello, I'm thinking how to deal with player interpolation. When one player shot while moving, another player will see the gap between player one old position (because it is interpolated) and bullet. Do you have and Idea how to fix that?

nocturne vapor
latent valve
#

my client is just floating there when it connects. any idea why?

#

the client can only look up and down and cannot move or do anything else

median gale
nocturne vapor
marble raven
#

Hi. I need shutdown server if host disconnects and disconnect client if client disconnects. In server case i understand what i need to do, but what about client, how to disconnect him?

private async void Start()
    {
        await UniTask.WaitUntil(() => UnitContainer.unit != null);
    
        Singleton.OnClientDisconnectCallback += (client) =>
        {
            if (UnitContainer.unit.IsServer)
            {
                Singleton.Shutdown();
            }
            else if (UnitContainer.unit.IsClient)
            {
                // ???
            }
        };
    }
deep briar
#

is it possible to use my own dedicdated server for matchmaking

#

using Netcode & unity game services

frigid pilot
#

Hello, im triying to collab with my friend with plastic SMC, and when he opens unity hub and search for "Open remote project" the project doesnt show up, even after i added him to the team, i tried a lot of things but nothing seems to work, could anyone help me please?

white ledge
#

is Mirror Networking useful now?
or it is deprecated?

sharp axle
spring crane
#

Got significant commits within the last 12 hours and the primary author is still selling assets that rely on it

coral shadow
#

Hi, im building a casual game that uses physics and networking.
I added the network object, network rigidbody and clientnetworktransform scripts to my prefab and successfully instanciate and spawn it.
The problem i find is that the scripts that add forces to my rigidbody do not affect it because the rigidbody is automatically set to kinetic.
How am i supposed to solve this?

#

Removing the network rigidbody seems to "solve" it, but i dont know if this is a good aproach tbh

sharp axle
gleaming zenith
#

I have a similar problem when I'm using a Client Network Transform and use the interpolate option the position of my character is not in the correct spot but when i turn interpolate off it works perfectly is their a way to fix this or should I brute force it and update the position through code?

pale bloom
#

Edit: I have figured it out, ty anyways

Hello, I have a question regarding tcp sockets
I have a server written in python which should accept connections from multiple clients in Unity
on the other side, clients should also receive data from the server

in python I avoid the blocking of socket.recv by using selectors
is there any elegant way of doing it in Unity or should I use select aswell?

I should state that speed is not important here, as it is a turn based game

sharp axle
gleaming zenith
sharp axle
gleaming zenith
# sharp axle Network Transform uses Network Variables under the hood

O ok Iโ€™m probably not gonna use the network transform and make a custom script for updating the player. I might blow up someoneโ€™s computer updating the position every frame lol. If u know how to uhh not do that and make a custom script to update the position#s it would be appreciated if not Its fine I appreciated the help

wraith violet
#

how would i send a list<int> though an rpc?

gleaming zenith
#

Could you instead make the list a network variable?

wraith violet
#

i don't think that works

#

๐Ÿ˜ฆ

gleaming zenith
#

Ooo my b

sharp axle
sharp axle
# wraith violet how would i send a list<int> though an rpc?

Arrays of C# primitive types, like int], and [Unity primitive types, such as Vector3, are serialized by built-in serialization code. Otherwise, any array of types that aren't handled by the built-in serialization code, such as string], needs to be handled through a container class or structure that implements the [INetworkSerializable interface.

gleaming zenith
sharp axle
wraith violet
#

(sorry if i'm cutting in)

gleaming zenith
sharp axle
wraith violet
#

um

#

i put "public class PlayerManager : NetworkBehaviour, INetworkSerializable"

#

i'm getting "'PlayerManager' does not implement interface member 'INetworkSerializable.NetworkSerialize<T>(BufferSerializer<T>)'"

sharp axle
wraith violet
#

uh

#

so the array? since i wanna pass a list<int> through an rpc

#

the rpc is in the class "PlayerManager"

#

sorry, i'm new to networking

#

i'm a little confused on how to serialize things, i've never done it before

wraith violet
#

network lists are just like networkvariables, right? it's just that they can hold lists

sharp axle
#

You might even be able to send NativeList<int> directly inside a RPC. I havent actually tried that

sharp axle
wraith violet
#

hm, interesting

#

sorry for all the questions

#

i'm very new

#

one last question: (hopefully), so since it's a networklist, that means that if a new client joins, they'll have the updated list, right?

sharp axle
wraith violet
#

ah ok

#

thank youuuu

#

if i were to ask questions about networking here, would you often be online at this time

sharp axle
#

link is in the pin message

wraith violet
#

wait what

#

whoa, revolutionary

coral shadow
sharp axle
coral shadow
#

Oh ok, so whenever a player hits the forwarded button I should send an rpc on each update?

#

Sounds intense

#

Ohh I could use network variables for that, right?

wraith violet
sharp axle
sharp axle
wraith violet
#

whoops, i thought i already reacted, but i didn't ๐Ÿคฆโ€โ™‚๏ธ

sharp axle
coral shadow
wraith violet
#

anyway, thanks evilotaku, i'm probably gonna ask you for help a lot in the future!

#

is it okay if i ping you around this time if i need help?

#

woo hooo

ionic mantle
#

Hello everyone, could anyone help get my started on how I could have a player press a button and have it teleport ONLY the player who pressed it to a certain spot on the scene? Im using netcode for go btw.

woeful raven
#

hello guys, so i am making fps game and i wanna make the skin and animations invisable to me and appears to the other guys in the game so what can i type in search to have a tutorial im using photon pun 2

neat veldt
warm lichen
#

with netcode for gameobject, theres a player prefab slot you can assign the network gameoibject to spawn on (server launch/ join), but how you do you for more than 1 model ?

ionic mantle
neat veldt
warm lichen
#

kk thanks will check that

warm lichen
#

@neat veldt what im looking to do is, have a different spawn of player prefab depending on what the player chooses, the code to allow the switch of character is ok, but i cant seems to switch player prefab with code before i join a server

neat veldt
#

I believe you can set an object to be the client's player after its spawned

sharp axle
# warm lichen <@308117922260451340> what im looking to do is, have a different spawn of playe...

With every new connection, Netcode for GameObjects (Netcode) performs a handshake in addition to handshakes done by the transport. This ensures the NetworkConfig on the client matches the server's NetworkConfig. You can enable ConnectionApproval in the NetworkManager or via code by setting NetworkManager.NetworkConfig.ConnectionApproval to true.

warm lichen
#

oh thnks ill look into that

tidal hemlock
#

Hello, I'm having trouble with rotation over the network (kindof) using netcode for gameobjects

I have an object thats being rotated by a client, and the rotation is being syncrhonized as expected on every other client + local client ...

but when I check the rotation through script transform.rotation.x/transform.localrotation.x or the direction transform.forward on other clients it says 0 even though on the inspector for the client (not local client) I can see the rotation from the owner client :\

regal gull
#

Hi, I am trying to use this native library https://github.com/ValveSoftware/GameNetworkingSockets

on my Unity project. I compiled the .dll but since it's native it doesn't get recognised when I build on Android, could someone tell me how to build the library for Unity Android?

GitHub

Reliable & unreliable messages over UDP. Robust message fragmentation & reassembly. P2P networking / NAT traversal. Encryption. - GitHub - ValveSoftware/GameNetworkingSockets: Re...

sacred maple
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using Unity.Netcode;

public class PlayerMovement : NetworkBehaviour
{
    public float speed = 10.0f;



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

        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");
        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
        transform.position = transform.position + movement * speed * Time.deltaTime;
    }
}
#

I have a linux VPS with a game server loaded up via Dedicated Server/Linux build and then a game clients loaded up via Windows on my local PC
The players spawn, but they don't register the other clients movements

#

player 1 falls -- gets moved to the left

Second window opened, player 2 falls on top of player 1 (whose movement to the left never updated to the server), moves to the right. First window shows player 2 idle on top of player 1's previous position

shrewd junco
sacred maple
#

@shrewd junco I'm already stuck...

#

I can't drag the player to the prefab slot and the prefab list

#

Only the prefab slot

shrewd junco
#

and you put your player inside the default network prefab list itself as well

#

pretty sure thats like the only difference

sacred maple
#

Sorry so

#

"Default Network Prefab List" where is this?

warm lichen
#

you need to create a network prefab list

sacred maple
#

Create a list in my assets folder? Or a folder in my assets folder

#

I've never made a list in my assets folder

shrewd junco
#

it should just be created by default, but if not then yea right click in your assets folder

#

itll be there under netcode

sacred maple
#

Thanks ๐Ÿ™‚

warm lichen
#

im not sure why all the tutorails shows the default player prefab method how usefull is this , to have the players all look the same look

shrewd junco
warm lichen
#

true, but still no tutorials on that

#

im not good with documentation that is sorta vague

shrewd junco
#

what i said is pretty much just how u would do it

shrewd junco
#
    // The Prefab hash value of the NetworkPrefab, if null the default NetworkManager player Prefab is used
    response.PlayerPrefabHash = null;

that part

warm lichen
#

i followed a tutorial that make sure connection aproval wroks,, i can move and animation network authoritive i just need to change player prefab so they dont look the same for every player, sec ill check your link

shrewd junco
#

if you scroll down, theres a part "changing the player prefab"

warm lichen
#

i did try to follow that but i ant make it to work

#

not sure if the script needs to be on network object

#

someone sent this earlier

shrewd junco
#

instead of doing
var playerPrefabIndex = System.BitConverter.ToInt32(request.Payload);
just assign that to some random one for now to see if it works

sacred maple
#

Sorry @shrewd junco

#

WASD doesn't work when I launch client

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using Unity.Netcode;

public class PlayerMovement : NetworkBehaviour
{
    public float speed = 10.0f;



    void Update()
    {
        if (!IsOwner) return;
        Debug.Log("Owner");
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");
        Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
        transform.position = transform.position + movement * speed * Time.deltaTime;
    }
}
shrewd junco
sacred maple
#

Where is this setting King?

#

I don't see it in the Network Manager, Network Transport, or Network Object

shrewd junco
#

server authoritative movement would mean you are using a network transform

sacred maple
#

Ahh...

shrewd junco
#

if theres no network transform or client network transform, your position/rotation/scale wont be synced across the network

#

unless you wrote your own custom one

sacred maple
#

Should I use client network transform then?

#

And remove Network Transform?

shrewd junco
#

if you want client authoritative movement then yea

tidal hemlock
shrewd junco
sacred maple
#

It's working ๐Ÿ™‚

#

Thank you so much

#

Do you think the issue was the pre fab list then?

#

I tried client transform before to no avail

shrewd junco
tidal hemlock
shrewd junco
#

the forward is just a vector

sharp axle
tidal hemlock
ionic mantle
#

Hello everyone. I am having an issue where I am using Netcode for GO and my player prefab that has a Client Network Transform. Attached to the base player prefab is a camera holder then a weapon object. The problem is that only the base player is visible to other players in the game. The client itself can see the weapon, but other players cannot see the weapon. Do I need to have a Client Network Transform on the weapon too? Am I missing something here?

sharp axle
ionic mantle
#

I figured, thanks.

gleaming zenith
#

Is it possible to enable and disable a Network Transform through code at runtime?

sharp axle
gleaming zenith
# sharp axle You should be able to disable the component

I thought so but when I tried to access the component it wouldnโ€™t pop up and when I looked online I couldnโ€™t find anything. Maybe I wasnโ€™t accessing it right because I was trying gameobject.GetComponent<> and looked for the Network Transform but couldnโ€™t find it but maybe Iโ€™m just being stupid

viral locust
#

I'm having an issue with Rpc :x

I run the server and then I run the client

in the client, I have a UI button to simulate the "login" button; when that button is clicked, I call a method that has the NetworkManager.Singleton.StartClient();

after invoking the NetworkManager StartClient, I have this line that returns null
FindObjectsByType<Player>(FindObjectsSortMode.None)

will FindObjectsByType only work once the method that starts the client ends?

if I press the button again, the FindObjectsByType<Player> does return the player

sharp axle
viral locust
#

ty ty will give it a try

zinc crow
#

Hey Im having a problem with my NetworkRigidbody.
Im using Unity Version 2022.3.5f1 and Netcode for Gameobjects 1.4.4 . I have one Player prefab with my Movement Script and a Network Rigidbody. On the host side everything works and the Rigidbodys are isKinematic = false but on the Client side its isKinematic = true. I dont know why. I tried to set the IsKinematic in the Await or the OnNetworkSpawn but both didnt work.

deep briar
#

how can i make change scene on finish matchmaking

ionic mantle
#

Hello everyone. I am having an issue where I am using Netcode for GO and my issue is that each player in a game has a gun and whenever they fire that gun it spawns a prefab of a bullet/projectile but I want to be able to syncronize those bullets over the network so that whenever a bullet hits a player that player knows and I also have a script where whenever a player gets hit with said bullet it kills them so I need these bullets to be networked. To go fourth in doing this would it be as simple as adding a network object and client network transform to each prefab, I am also using Relay so would relay interfere with that since im not sure if it automatically adds that bullet to the relay session. Anybody got any ideas. Im not even sure that the best way to detect if a player is hit by a bullet is just to check if it was collided with an object with a bullet tag. Thanks!

ionic mantle
#

I had tried a raycast previously but I ran into the same issue of how can I let others players know that they have been hit by the raycast.

shrewd junco
shrewd junco
ionic mantle
shrewd junco
# ionic mantle I figured. I have never really understood ServerRPC's tbh.

its something u just need to play around with, it gets especially confusing if you dont know where its running.
a server rpc (remote procedure call) means you are remotely calling the server to a procedure. To simplify: you are telling the server to run some code. Only a client can call this (a host is a client and server, so hosts can call it).

#

in your case you would likely want a client rpc, so the server is telling the clients that someone got hit.

ionic mantle
#

Thank you.

thorny gale
#

is there a way of loading addressable scenes with NGO

nocturne vapor
mint anvil
#

quick question should i switch from mirror to fish-net ?

normal peak
#

I am using a player controller that uses to separate camera holder and player how will i use it as a prefab for photon pun 2

fluid walrus
sharp axle
lean latch
#

does anyone know what mirror's networkserver.active equivalent for netcode?

sharp axle
ionic mantle
#

Hello everyone. So I am having an issue with a ServerRPC. I finally decided to learn how to use it yet im still after all this time still confused. This https://pastebin.com/xWh5yjLS is my code for Instantiating a bullet. The 4th line just created a game object (a projectile) and instantiates it and then spawns it at the firePoint. Then on the 6th line it gets the RigidBody of that projectile and makes it go fast like a bullet. But Unity is yelling at me telling me that it does not know how to serialize or deserialize UnityEngine.Transform.RPC. I new to networking and have no idea what that means so I looked it up and it told me to add INetworkSerializable after the class and I did then untiy yelled at me again saying it does not know how to implement a surface member of INetworkSerializable and I am unable to figure out why after looking it up, again I dont know at all what a INetworkSerializable is or why I need to use it.

icy prairie
ionic mantle
#

Makes sense. Thanks

gleaming zenith
#

using the NetworkManager.SceneManager.LoadScene im trying to load into another scene the only problem is the server host loads in way before the clients even when load scene time out is set to 0 is their a way to make it so the scene only loads when all the clients are ready? the line im using to load the scene is below
NetworkManager.Singleton.SceneManager.LoadScene("MiniGame", LoadSceneMode.Single);

sharp axle
gleaming zenith
#

yield return new WaitWhile(() => SceneEventType.LoadEventCompleted.Equals(true)); I just did this I have no clue if this will work heres trying

sharp axle
gleaming zenith
gleaming zenith
vagrant elm
#

I have created a multiplayer game using two separate Unity Editors, and have successfully connected to a Pun2 server. How can I connect both editors to the same room?

sharp axle
woven cliff
#

Im using Lobby by unity can anyone help me fix this? providing code and console screenshot

    public async Task CreateLobby(string lobbyName, bool isPrivate, string playerName)
    {
        Debug.Log("Creating Lobby");

        Debug.Log(lobbyName);
        Debug.Log(isPrivate.ToString());
        Debug.Log(playerName);

        try
        {
            Debug.Log("1");
            CreateLobbyOptions options = new CreateLobbyOptions()
            {
                IsPrivate = isPrivate,
                Player = CreateLobbyPlayer(playerName),
            };
            Debug.Log("2");
            Lobby lobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName, maxPlayersPerLobby, options);
            Debug.Log("3");
            hostLobby = lobby;
            Debug.Log("4");
            StartCoroutine(StartLobbyHeartBeat());

            Debug.Log("Created Lobby");
        }
        catch(LobbyServiceException e)
        {
            Debug.Log(e.Message);
        }
    }
woven cliff
#

i think i found the issue

#

im logging in to slow

#

how do i fix this?

#

fixed it by making a while !ready loop that waits 1 second untill ready is true and i set ready to true after logging in

swift belfry
#

Hello everyone, Iโ€™m having trouble with ServerRpc and ClientRpc methods not getting called

If anyone could help me out I would appreciate it!
The following code is attached to NetworkObject and the script is NetworkBehaviour:


// Is called from button click listener
private void ReadyToPlay()
    {
        isLocalPlayerReady = true;
        OnLocalPlayerReadyChanged?.Invoke(this, EventArgs.Empty);
        Debug.Log("CALLING RPC ");
        SetPlayerReadyServerRpc();
        Debug.Log("FINISH RPC ");
    }

[ServerRpc(RequireOwnership = false)]
    private void SetPlayerReadyServerRpc(ServerRpcParams serverRpcParams = default)
    {
        Debug.Log("IN SERVER RPC, ID: ");
        Debug.Log(serverRpcParams.Receive.SenderClientId);
        playerReadyDictionary[serverRpcParams.Receive.SenderClientId] = true;

        bool allClientsReady = true;
        foreach (ulong clientId in NetworkManager.Singleton.ConnectedClientsIds)
        {
            if (!playerReadyDictionary.ContainsKey(clientId) || !playerReadyDictionary[clientId])
            {
                //Player not ready
                allClientsReady = false;
                break;
            }
        }
        
        Debug.Log("All players ready: " + allClientsReady);
    }

// Even these test ones don't work
[ServerRpc(RequireOwnership = false)]
    private void TestServerRpc(ServerRpcParams serverRpcParams = default)
    {
        Debug.Log("TEST SERVER RPC");
    }

    [ClientRpc]
    private void TestClientRpc(ClientRpcParams clientRpcParams = default)
    {
        Debug.Log("TEST CLIENT RPC");
    }

(I sometimes get this error too: [Netcode] Deferred messages were received for a trigger of type OnSpawn with key 0, but that trigger was not received within within 1 second(s).)
I am trying them as host and client with no success. Thanks again!

shrewd junco
#

the reasons its not calling is likely due to the network object changing ID's

swift belfry
shrewd junco
#

use a !code website itll be easier

raw stormBOT
#
Posting code

๐Ÿ“ƒ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

๐Ÿ“ƒ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

swift belfry
shrewd junco
#

maybe try to separate out some things that you know arent relevant

#

is there anything that is calling despawn/spawn on this object

swift belfry
shrewd junco
#

when you call the RPC, can you look at the network object ID and just see if it changes?

swift belfry
shrewd junco
#

with the amount of logic in here, its hard to see if anythings really disabling/enabling or respawning the object but from what i saw it doesnt look like it

#

also when u are testing this, are u checking debugs on the host/server?

swift belfry
shrewd junco
#

are u spawning this GameplayManager then dynamically, aka its not in the scene when u press play

swift belfry
#

But not spawning through server

shrewd junco
#

i forgot how network objects work when that happens, let me try something

shrewd junco
#

regardless the issue is still just that its not spawned/despawning somehow

#

which u can fix by calling the .Spawn() function

#

the only thing is something like this should be spawned already

swift belfry
#

Yea that's why I didn't think that would be an issue

swift belfry
shrewd junco
#

which makes sense

swift belfry
shrewd junco
swift belfry
shrewd junco
#

the order shouldnt matter as long as this is after the network manager is listening

#

u can also ask in the ngo discord pinned in here. a lot more gets answered in there

swift belfry
woven cliff
#

in netcode for game object can i not spawn the player objects as soon as the game starts and only later when i call a function if not can i not spawn player objects and then asign a player object to a player? i have code taht works by getting the player object so woud be helpful if someone cud help to find an answer

lunar urchin
#

hey guys looking for experts in UX/UI for VR

oak flower
#

@lunar urchin If you are looking to ask a question, ask in #๐Ÿ“ฒโ”ƒui-ux , if you are looking for !collab:

raw stormBOT
viral locust
#

all the network tutorials I see for a mmorpg is either with lobbies or steam ids...

what's the best way to host my server in a 3rd party platform, like amazon or w/e, and make the client connect to the server?

viral locust
#

I did read about fishnet and the asset is free, right?

oak flower
viral locust
#

will have a look on this

#

ty

oak flower
#

@drowsy thistle !collab for job posts etc.

raw stormBOT
shrewd junco
cunning sluice
#

So I'm having an issue with PUN 2
I enable the Offline Mode but it doesn't seem to use the callback OnConnectedToMaster like it says in the documentation.
I have a Debug Log in there that is never called, but it definitely sets the photon network to offline right away in Awake as long as I have the bool enabled.

Anyone know what I'm doing wrong?

    private void Awake()
    {
        if (offlineMode)
        {
            PhotonNetwork.OfflineMode = true;
            //InitConnect();
            return;
        }

        //Player is already connected to the network, just return
        if (PhotonNetwork.IsConnected) return;

        //If it's a first boot, get mic permissions
        if (askForMicPermission && !Permission.HasUserAuthorizedPermission(Permission.Microphone))
        {
            Permission.RequestUserPermission(Permission.Microphone);
        }

        //Start the connection
        InitConnect();

    }

    public void InitConnect()
    {
        ConnectToServer();
    }

    public void ConnectToServer()
    {
        PhotonNetwork.ConnectUsingSettings();
        PhotonNetwork.GameVersion = GAME_VERSION;
        PhotonNetwork.ConnectToRegion(DEFAULT_REGION);

        Debug.Log("Attempting Connection to Server");
    }

    public override void OnConnectedToMaster()
    {
        Debug.Log("Connected To Network!");

        //Connecting to the Lobby to load active lobbies
        PhotonNetwork.JoinLobby();
    }
bleak rover
woven cliff
#

im using lobby by unity and if i try to join a lobby from a second instance of the editor it tells me im already in the lobby is that becose im on the same pc?

sharp axle
woven cliff
#

Also how can I run code when someone joins the lobby

woven cliff
#

I tried a person had the same problem in this discord it also didn't existed for them

sharp axle
woven cliff
#

Not home rn I will try when I get back

#

@swift pendant this guy might know how to fix your problem

swift pendant
sharp axle
# swift pendant hi, do you know how to use the latest version? I can't upgrade it from 1.0.3 to ...

Oh it might still still be in preview. You should be able to add it by name and specify the version. 1.1 I think
https://github.com/Unity-Technologies/com.unity.services.samples.game-lobby#ugs-events-beta-note

GitHub

A sample showcasing a minimal implementation of a lobby experience using the Lobby and Relay packages. - GitHub - Unity-Technologies/com.unity.services.samples.game-lobby: A sample showcasing a min...

swift pendant
#

@woven cliff so add it with name, package manager add by name:
name: com.unity.services.lobby
version: 1.1.0-pre.5

woven cliff
cunning sluice
somber geode
#

Hey i Wanna send From my phone App Data to the server which Runs my Game. The App is Build With js and i dont know How to approach this

#

Making it With sockets Would be an Option But Would Like to make it With a Unity Solution that Deals With data transfer

gleaming zenith
#

How do you send information to a specific client? when trying this code and plugging in the targetId of a different client nothing gets received on the other client.
UpdatePlayerPositionClientRpc(transform.position, new ClientRpcParams
{
Send = new ClientRpcSendParams
{
TargetClientIds = new ulong[] { TargetId.GetComponent<NetworkObject>().NetworkObjectId }
}
});

shrewd junco
#

id also just cache that client rpc params into a ClientRpcParams clientRpcParams
then call the function with UpdatePlayerPositionClientRpc(transform.position, clientRpcParams);
would be a lot cleaner on the eyes at least

#

plus you can save some memory allocations if your target id doesnt change often

gleaming zenith
woven cliff
#

in unity lobby how do i run code when someone joins any lobby cus doing it when someone presses the join button is error prone cus there are multiple

#

cus from what i understand subscribing to events require the player to already by in some lobby

mighty whale
#

So is it not true that player objects are assigned their own ownership?

#

Thats what im currently working with. Using client network transform

shrewd junco
shrewd junco
# mighty whale https://hatebin.com/bnwtuecrqy

Also what you are doing in update looks very very wrong. You are adding code to an event every single frame by the looks of it, yet never removing any so this is gonna grow very quickly. The formatting of this seems very... different too

mighty whale
#

Ohhh and that makes sense

shrewd junco
mighty whale
#

Actually Iโ€™ve already completed multiple projects

#

Again, itโ€™s prototype code, itโ€™s not intended to be perfect, just enough to get things running

#

I use KR formatting, and I try to use Microsoftโ€™s coding conventions.

#

As a matter of fact Iโ€™ve been working in Unity for two years now so savage

#

If I want to make multiplayer games Iโ€™ll need to make the step at some point

shrewd junco
mighty whale
#

No worries, to be fair Id think the same with lambda events assigning in a loop

#

Iโ€™m fairly embarrassed thatโ€™s in there

#

Iโ€™ve been meaning to refactor this into 3 scripts anyways so maybe Iโ€™ll do that tomorrow.

mighty whale
small hamlet
#

I want to make a skill based matchmaking system using photon.

Currently I have done so by

-> get all active rooms in lobby
-> filter all the rooms and only look at ones that are near my skill level
-> try finding a room who's MMR is close to mine
-> if can't find after 5 seconds, create a room

Is there a better way of achieving it?

woven cliff
#

in unity lobby how do i run code when someone joins any lobby cus doing it when someone presses the join button is error prone cus there are multiple

woven cliff
#

also in unity gaming services can i somehow log into a anonomys account with a specific id? so i cud use it accros multiple deveices?

somber geode
small hamlet
#

@somber geode I used photon

woeful raven
#

so im using photon pun and i wanna make it instantiate one gun in random place but it instantiate a gun for every player and idk why

this is the script:

    public GameObject gun;
    public float minX , maxX , minY , maxY , minZ , maxZ;
    // Start is called before the first frame update
    void Start()
    {
         Vector3 randomPosition = new Vector3(Random.Range(minX, maxX), Random.Range(minY, maxY), Random.Range(minZ, maxZ));
         Debug.Log($"Spawning at: {randomPosition}", gameObject);
         Instantiate(gun, randomPosition , Quaternion.identity);
    }
spring crane
tawdry walrus
#

private NetworkVariable<List<Card>> deckSync = new NetworkVariable<List<Card>>(); how i can create a networklist to manage a deck ?

#

i'm using relay and ngo

tawdry walrus
#

how i can extend INetworkSerializable in my card class? is correct extend MonoBehaviour?

#

@frank stream pls u can help me, pls i need this game for university exam

frank stream
#

/// </summary>
public struct AreaWeaponBooster : INetworkSerializable, System.IEquatable<AreaWeaponBooster>

#

that's how you do it, look at the example

#

how do you have an exam on this but have no knowledge how to extend from a class implementation

tawdry walrus
#

yes i see the example but i have class not struct, i convert my class in struct, and this example i try before but not work for me

frank stream
#

because struct are better suited for network transfer

#

you can just change it to struct, not much will change

#

Reference types are part of complex types though, make sure you read up on that too

tawdry walrus
frank stream
#

then why do you have an exam on this ? have you coded a game before?

tawdry walrus
#

no never i code game but in my university last year we need 2 facoltative exam and game developer is a interresting

#

[System.Serializable]
public struct Card : INetworkSerializable {

public string cardName;
public Sprite image;
public int maxCard;
public Heat heat;
public Cash cash;
public Protection protection;
public Nirvana nirvana;
public Maledizioni maledizioni;
public Effects effects;
public bool inDeck;
public bool onBoard;
public int usedCards;
public GameObject UIimage;

public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
    if (serializer.IsReader)
    {
        var reader = serializer.GetFastBufferReader();
        reader.ReadValueSafe(out cardName);
        reader.ReadValueSafe(out maxCard);
        reader.ReadValueSafe(out heat);
        reader.ReadValueSafe(out cash);
        reader.ReadValueSafe(out protection);
        reader.ReadValueSafe(out nirvana);
        reader.ReadValueSafe(out maledizioni);
        reader.ReadValueSafe(out effects);
        reader.ReadValueSafe(out inDeck);
        reader.ReadValueSafe(out onBoard);
        reader.ReadValueSafe(out usedCards);
        reader.ReadValueSafe(out UIimage);
    }
    else
    {
        var writer = serializer.GetFastBufferWriter();
        writer.ReadValueSafe(out cardName);
        writer.ReadValueSafe(out maxCard);
        writer.ReadValueSafe(out heat);
        writer.ReadValueSafe(out cash);
        writer.ReadValueSafe(out protection);
        writer.ReadValueSafe(out nirvana);
        writer.ReadValueSafe(out maledizioni);
        writer.ReadValueSafe(out effects);
        writer.ReadValueSafe(out inDeck);
        writer.ReadValueSafe(out onBoard);
        writer.ReadValueSafe(out usedCards);
        writer.ReadValueSafe(out UIimage);
    }
}
#

my new struct

#

but i have this

#

write is wrong

frank stream
woven cliff
#

how can i delete a username password account cus i accidently deleted the player ID assosiated with it and i need to either assign a new one or just delete the username password and make it again how can i do that? using unity gamking services btw

tawdry walrus
#

eeeem i know but i work on this from 2 mouth and i cant change now

frank stream
#

wowz why did you wait so long? didn't you realize networking was extremely difficult?
Idk mate you're in a difficult spot cause you're trying to race a F1 car without knowing how to drive

frank stream
woven cliff
#

method of authentication

woven cliff
tawdry walrus
#

u can help me ?

frank stream
tawdry walrus
#

i need this for december or next year

frank stream
tawdry walrus
#

i think i do singleplayer after i need change to much

#

i create strcut without error now but i use card class to link with gameobject now with struct i cant, is uselles link?

frank stream
tawdry walrus
#

I really appreciate the advice but I think I should do the multiplayer version directly for timing

nocturne vapor
ionic mantle
#

So I have a network variable that looks like this

public NetworkVariable<int> health = new NetworkVariable<int>(
    value: 120,
    NetworkVariableReadPermission.Everyone,
    NetworkVariableWritePermission.Owner);

and what happens is that whenever a person shoots someone it subtracts the health by the amount of damage a gun does. Then when it detects the players health is under 0 it kills them then resets their health back to normal. A client shooting a host works just fine and nothing goes wrong. But a host shooting a client does not work and the host gets the error Client is not allowed to write to this network variable even though the write permission is set to owner and the read is everyone. I also tried using Server instead of owner and it worked kinda, the host was able to shoot the client and the client was able to shoot the host but their health never got reset back to 0 and on the client this time was saying the client was not allowed to write to the network variable.

woven cliff
#

in unity lobby how do i run code when someone joins a lobby?

woven cliff
nocturne vapor
drowsy pelican
shrewd junco
shrewd junco
drowsy pelican
#

theorically you just need change the ip address to my local ip address

shrewd junco
drowsy pelican
#

I thiked about this also, but in his tutorial he didn't activate it

shrewd junco
drowsy pelican
#

"it is recommended to leave remote connections disabled for local testing t avoid exposing ports on your device"

woven cliff
#

In unity lobby how do I run code when you join a lobby for example to show the in lobby ui

nocturne vapor
#

also if you are developing on windows, it could be that you need to change some firewall settings

cloud cape
#

hey guys I am doing Photon PUN2 multiplayer game, first player creates a room then joins a game, second joins room and then the game, my problem is when the second player joins, his avatar spawns twice(when you are first player then you spawn correctly only once)
this is my code

#

the script is attached on a gameobject that is already on the map, so it instantiates the player, when he loads the scene

drowsy pelican
nocturne vapor
drowsy pelican
cloud cape
#

ok got it

drowsy pelican
#

only in one computer*

drowsy pelican
#

@nocturne vapor ok I tried, still the same problem

#

ok finally I found the solution

#

activate Allow Remote_Connection + disable firewall

nova linden
#

i need to spawn a gameobject, but only the server is able to do so, the logical solution is to create a ServerRPC funktion. But here comes the problem, the server rpc funktion cant use refrences required to spawn objects

#

am i missing something ?

gleaming zenith
#

you can use a ulong to send a gameobject in the Rpc function

nova linden
gleaming zenith
#

I dont know if this is correct but if you call a server rpc that calls a clientRpc with the gameobject I think that would work

#

I keep getting this error when trying to use the NetworkAnimator when I click on the error its telling me that
m_NetworkAnimatorStateChangeHandler on the actual NetworkAnimator script NullReferenceException: Object reference not set to an instance of an object
does anyone know how to fix?

mighty whale
#

So I think Praetor is suggesting I should move this issue here.

Networking Solution: UNGO

Issue:
So currently my player uses the PlayerInput and InputAction systems, along with Cinemachines free look component. When new players connect the camera pans over to the most recent player that connected, But as far as I understand this shouldnt happen as the camera is not a synced object, thus its a bug.

Intent:
My camera should maintain its currently viewed character in each instance of the game. My current solution that does not work is:

https://hastebin.skyra.pw/uzugubimax.csharp

raw thorn
mighty whale
#

They are the same prefab, so no

raw thorn
#

I put in my playerscript something like ```[SerializeField] private CinemachineVirtualCamera virtualCamera;
[SerializeField] private int cameraPriority = 11;

if (IsOwner)
{
virtualCamera.Priority = cameraPriority;
}```

#

So if you're the owner of the gameobject then the camera stays with you, else it just swaps over to the newest player I think. If I'm understanding your problem correctly.

mighty whale
#

I shouldve known

#

Thank you so much

raw thorn
#

I wouldn't have known either if the course I did last month didn't tell me ๐Ÿ˜› You're welcome.

mighty whale
#

I dont normally work with cinemachine, but its got a lot of baked in features I shouldnt reinvent so thanks for the help

nocturne vapor
#

Same for ui btw

raw thorn
#

Yeah that might even be better, my solution was more based on having just 1 camera in the entire scene, but I see now that you've placed the camera on your prefab .

mighty whale
#

My camera is on the scene level

#

my cinemachine freelook is on the character

#

the view you see is the prefab level

raw thorn
#

ah ok, the camera object is just an empty then ๐Ÿ™‚

mighty whale
#

Yes

#

Well no

#

its the parent

#

oh yeah its empty in terms of components

young stag
#

I can't find the checkbox ๐Ÿ˜ฆ

nocturne vapor
young stag
#

I can't find the desired property or method in NetworkManager.Singleton

nova linden
#

If i destroy network objects there are still ghosts of them frozen in time on all other clients

#

Even if i call the networkobject.despawn funktion

rose lake
#

whats a good udp libary do yall recommend that has built in reliable/unreliable data

rose lake
shrewd junco
meager rain
#

Anyone have idea how to set parent of an instantiated prefab in Photon?

woeful raven
#

why does it instantiate whenever a player joins i want it to instantiate one time only im using photon pun

this is the code:

 public GameObject gun;
    public float minX , maxX , minY , maxY , minZ , maxZ;
    // Start is called before the first frame update
    void Start()
    {
         Vector3 randomPosition = new Vector3(Random.Range(minX, maxX), Random.Range(minY, maxY), Random.Range(minZ, maxZ));
         Debug.Log($"Spawning at: {randomPosition}", gameObject);
         Instantiate(gun, randomPosition , Quaternion.identity);
    }
nova linden
#

can i pass a TrailRenderer through a ulong ? same thing for a RaycastHit

viscid moat
nova linden
#

what exactly isnt working

viscid moat
#

I have that method

    void SyncVariableClientRpc(NetworkVariable<Output> currentServerState)
    {
        if (IsHost)
            return;
        this.currentServerState = currentServerState;
    }```
this is called on the server, I make sure my `Output` is network serializable 

[System.Serializable]
public struct Output : INetworkSerializable
{
public int tick;
public Vector3 pos;
public bool isMoving;

public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
    serializer.SerializeValue(ref tick);
    serializer.SerializeValue(ref pos);
    serializer.SerializeValue(ref isMoving);
}

}```
but in the console I get errors that unity dont know how to serialize NetworkVariable<Output>, so I've made that method

public static class SerializationExtensions
{
    public static void SerializeValue<TReaderWriter>(this BufferSerializer<TReaderWriter> serializer, ref NetworkVariable<Output> val) where TReaderWriter : IReaderWriter
    {
        var o = val.Value;
        serializer.SerializeValue(ref o);
        val.Value = o;
    }
}```
but it still not working
viscid moat
viscid moat
nova linden
#

you could just pass in the tick, pos and isMoving variables speratley. If it is a network variable you dont need to sync them manually. a and b ar just defaul inputs like ints or floats like any other funktion

viscid moat
#

But network variable aren't synced immediately, but I need that feature, and also when new players will join I want that they will know last state of other players, so I need somehow combine functionality of NetworkVariable and ClientRpc.

nova linden
#

thats too complicated for me sorry

viscid moat
#

No problem, I am struggling with that for couple days ๐Ÿ˜ and I'm starting to thinking that I will not be able to do this in that way

sharp axle
gleaming zenith
#

I have a throw command in my game that adds force to a RB but when my client uses the throw the rigidbody slides way further than when the server/host does anyone know why?

regal delta
#

type casting correct?

#

Does NetworkRigidbody work for you?

shrewd junco
gleaming zenith
shrewd junco
#

I tried something similar when learning, it doesnt go well because the clients dont see the correct values. For example if your client tried to add force to jump, it would likely try to apply it multiple times before the object even got off the ground server side

gleaming zenith
#

I made it completely client authoratative to check and its still happening

gleaming zenith
sharp axle
#

It will need to have a client Network Transform and rigidbody as well as be owned by the client too

gleaming zenith
gray warren
#

Hey, I was wondering about Netcode and multiple games on a single server. Is NetworkVisibility the way to go? Hiding GameObjects from each player according to their "room ID" or something? What about scene management? If I Load a scene per room, I didn't see a way in the docs for hiding scene loading events from certain clients (i.e. all players on the server will know that some other room is loading a scene).

drowsy pelican
#

I have this error : Only the owner can invoke a ServerRpc that requires ownership!
UnityEngine.Debug:LogError (object)
PlayerNetwork:functionServerRPC (char) (at Assets/PlayerNetwork.cs:0)
PlayerNetwork:<Start>b__5_0 () (at Assets/PlayerNetwork.cs:22)
UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:514)

sharp axle
sharp axle
drowsy pelican
#

Ah ! Yeah exactly. Thanks for that info will try it

tulip ledge
#

Hello,

I am interested in developing a multiplayer game and I am currently collecting information about potential technologies and capabilities that I could incorporate. I have been looking into Unity Services, and I'm particularly interested in using features like authentication.

The ideal setup for my game includes a backend server which allows API calls. These API calls should facilitate actions such as claiming daily rewards and retrieving user information from a database.

The game itself will feature 1vs1 turn-based battles. All of these battles need to be authenticated by the server, and the players' stats should be updated on the backend after each battle. After the update, players should be able to claim their rewards. This is a high-level overview of my project.

However, there are still some aspects I'm unsure about. For instance, I want to understand how I can allow a server to modify player stats on the database through Unity's netcode. I'm also not sure which Unity services would best suit my project's needs. My experience with this is limited, so I'm also looking for a matchmaking system that could match players based on specific stats.

Could someone please advise me on which technologies I should be looking into, so that I can start learning about them? I would prefer to use Unity-based solutions wherever possible.

nova linden
#

i have a question, i have guns with raycast hit detection and im using a Trail renderer that is instantiatet at the tip of the barrel and then moved to the raycastHit.point I want this line to show up for everyone but the problem is that only the host can spawn network objects and if i call a serverRPC that has a massiv delay and if you are a client and you shot you will see the line with a huge delay, how do other games do something like this

weary tangle
#

Assalam Alaikum.
In a drag race, a player's car reaches finish line. How can I then display a "You Won" and "You Lost" messages on the two different players using RPC calls in Photon?

split hedge
#

Hey how can I use NGO for taking damage as aplayer if it collides with something?

shrewd junco
shrewd junco
rose lake
#

what are some good suggestions for netcode?

#

currently looking at Riptide

drowsy pelican
#

any idea why I have this in my chat system ?

#

i just wrote hello, and it showed hello =\n and blanck line

somber geode
#

Maybe put \n in Single Quotes, specify encoding make the String a fixed length? Tried to find a Solution But idk where the = comes from.

#

Or try Environment.NewLine

drowsy pelican
#

@somber geode it is working well with only the host, but a client connect it doesn't. It seems

drowsy pelican
#

ok i finally found the solution, was missing if(IsOwner)

nova linden
#

Whats faster, a client that calls a server rpc that calls a client rpc that causes an event or a network variable that when changed causes an event ?

split hedge
#

Hey I have this, when I shoot on the client it will only shoot in one direction, not where the mouse is

nocturne vapor
nova linden
#

thank you

#

how exactly do i despawn networkObjects for everyone, since only the server can destroy it and i cant pass an object refrence trough the server rpc

#

and sinmply calling the destroy funktion leaves the object floating in the air

nocturne vapor
spring crane
nova linden
#

I use unitys networking framework

spring crane
#

Yea either it works automagically or you do the sending and look up youself. Haven't used Unity's solution.

nova linden
#

But marsimplodations idea should work

sharp axle
nocturne vapor
rustic lagoon
#

Hello guys, i try to setup a character controller with NetCode, i succesed by sending the Inputs to the Server, calculate position on the Server, and send it back to client, Works perfectly, Then I added a little bit of Delay,Jitter and Paket Lost and the experience was awfull and beside that, i was sending RPC at tick rate (the input, and i dont know if this is ok or not)
Is this how things sound work?
And i try to make the player move its avatar, but cant really succed here, its like "Any move i make has to be on server"

median gale
meager rain
#

i don't know what to call this phenomenon, happens on instantiation of chess pieces... any name for this bug? i don't care about the position of chess pieces on player 2 but on player 1 the pieces are looping/lagging/whatever

nova linden
#

How can i get the client id of the client that runs a script?

#

in unity netcode

#

or better said, i have a server -> client rpc and i dont want whatever hapens in the client rpc to happen for the person that called the server rpc, how would i do that ?

nocturne vapor
blissful vortex
#

Uh sorry then

weak plinth
#

hi , i want to make my game to be able to hold up to 4 players in multiplayer, what are my best options, easier they are better they are. Latency and such stuff is not as important, its a co op. what is important that it is easy to set up, and that i can put it on steam after its all done, thanks

burnt frigate
#

hi, i have a basic game that works nicely in single player, but i want to make it multiplayer, and since i am a pretty poor person i can't afford servers and stuff like that, so i found a solution : host the game on the players device by using their IP , (like some old games used to do) however i have absolutly no idea how to do that in unity (i tried to look similar ideas online but i did not see anything that helped which is why i came here), i you could help me that would be greatly appreciated.

sharp axle
sharp axle
nova linden
sharp axle
nova linden
#

okay

#

thanks

weak plinth
#

how is unity netcode for gameobjects, has anyone tried it and can confirm its easy to set up?

shrewd junco
weak plinth
#

so im wondering which one is best considering il have finished game that needs to be implemented to multiplayer

shrewd junco
#

The steps I usually do are code 1 feature to work in single player just to make sure it works, then make it work in multiplayer

nocturne vapor
weak plinth
weak plinth
#

and also if i want single player game to work in offline for example, it wont be able to work without a host etc. that netcode needs

shrewd junco
#

I dont have much multiplayer experience, but generally if your plan is to rewrite something from the very beginning then you're doing something very wrong. It's possible, but a LOT will change

shrewd junco
weak plinth
#

yea but that means its still online game just with 1 player

#

i dont understand honestly what in the code will change that drastically

#

arent things just gonna be added to it?

#

i got very little experience with multiplayer i hardly understand how to make it but i kinda understand how it works

shrewd junco
weak plinth
#

but wouldn't the network manager threw an error if you are offline?

nocturne vapor
#

No it wouldn't you can host a game completly offline

weak plinth
#

ok thats cool

#

well im still in very early development of my game but i really want to make it endless co op zombie shooter with 2-4 players

#

preferably 2 tho

shrewd junco
# weak plinth arent things just gonna be added to it?

No basically any action that everyone should see will have to change. It really depends on if you use server or client authoritative, but you're gonna be adding a lot of logic in your code to make sure the wrong person isnt trying to update a value

weak plinth
#

like left 4 dead or call of duty black ops zombie mod

#

but endless

shrewd junco
#

Shooting, moving, swapping levels, reloading, building, all of these features will require a rewrite

#

Just as quick examples

weak plinth
#

i mean i dont know honestly i know something but il have to do alot of reading before i start it myself

#

i now have pretty much my character set and 1 npc and now im thinking will i go the way to develop it single player first or start working on multiplayer aspect of it

#

by character i mean whole gunplay(recoil,animations,reload,ammo,weapon switch,etc)

#

i made map design and added 1 mob and working on another

shrewd junco
#

That's how you can sync components, but the same single player code wont just work. You'll be going back and adding a lot of network variables and stuff like if(isOwner). Its just way way easier to write by doing multiplayer the entire time

weak plinth
#

but IsOwner is still just adding to it

#

and variables is like 1 sec of rewrite

#

is it really that difficult?

shrewd junco
#

I provided like the simplest rewrite as an example, but remember this is gonna have to be in a lot of scripts. If it really doesnt deter you that you would have to go edit almost every script you've made then you can try. I just dont think a single person out there would recommend doing it this way

weak plinth
#

its not a problem for me to dive into it i think im pretty ready

#

but, can u tell me is netcode for gameobjects going to be simple to combine with steam

#

and is there something i should look after when aiming for it to be steam game

#

?

shrewd junco
#

Like let's say you want to swap weapons, that's super easy locally, just activate/deactivate it. When it comes to networking, now you have to send some data to the server who sends this to all clients saying which one you equipped

weak plinth
#

yes that is true, but it will still only add to it i believe?

shrewd junco
weak plinth
#

Ok well i better get into it then

#

thanks for your time

shrewd junco
nocturne vapor
#

I can give you an example for a rewrite
My player inventory is local and thats the way I want it to be
To write to my database however the host needs access to all the data in it, so I needed to write a complete class which accesses the player inventory processes important identifiers (steamid, slotnr, itemname, item count) and sends them to the server. The host/erver will now have a copy of that inventory and can write it to the database
In order to retrive that same inventory I have to do everything in reverse, so it is not just adding network variables

weak plinth
#

and honestly i though network manager / network transform already had those included

nocturne vapor
weak plinth
#

by probably ADDING something haha

#

But i do understand your points if u didnt prepare it well for those steps you probably had to rewrite some stuff

nocturne vapor
#

The problem is that you need to structure everything in a certain way and generally it is not recommended to add multiplayer to a game after you have written the core mechanics. You need to design these mechanics with multiplayer in mind

#

Thinking about where to execute what

weak plinth
#

yeah okay im all ears guys, but i do need advices thats why I am here

#

i really appreciate ur time but can u tell me where should i learn more about netcode for gameobjects

#

i saw a good tutorial by CodeMonkey on YT but i need to read more of it and understand it better

nocturne vapor
#

Codemonkey has a course on youtube and the rest is honestly reading the official docs and experimenting

#

Thats how I learned it

weak plinth
#

how long it took you?

#

honestly

#

to master it

#

i mean not to master it, but to be able to use it alone without googling much

#

or just using it

#

also im sorry for all questions, but how do you create rooms for your game?

#

with netcode

#

how does that work?

nocturne vapor
#

Oh and arguing with chatgpt. I find it very helpfull to share my thoughts with it.
Like describing a problem and than what you did to solve that problem if this is a good aproach
It is just to organize your mind and to get feedback

nocturne vapor
#

I still look up things in the docs

oak rain
#

qq: does unity have any built in utilities for transfrom prediction based on previous samples? i'm looking for somethiing better than dead reckoning that will factor in angular velocity.

nocturne vapor
nocturne vapor
weak plinth
#

i've never had nothing to do with steam im pretty much a begginer and this is what i want to be my first steam published game

nocturne vapor
oak rain
nocturne vapor
#

Sadly no

weak plinth
nocturne vapor
#

It would be, but you will probably have more luck trying it here. I try to reguraly look into this chat and some others like evilotaku and bawsi do as well always ready to help

weak plinth
#

cool, thanks

shrewd junco
shrewd junco
nocturne vapor
# shrewd junco Just curious, is the invite code gonna be the same thing for someone everytime? ...

No every lobby has a id attached to it, to identify it. Since steamids are also used for everything else alot of it is boiler plate, readable in the steamworks documentation and other places.
I have put in comments what stand for what.
A certain part of that id is truly unique, I take that part out of it, thanks to chatgpt and the good documentation I got the correct binary places, and convert these numbers into numbers and letters.
The important part is it is not hashing but base conversion so 1 to 1 and not with any conflicts. That way I can put it back into a steamid and join the lobby with that

#

So it has to do with the lobby not the owner and that id is not the same everytime

shrewd junco
weak plinth
#

im sorry but i dont see that?

shrewd junco
shrewd junco
weak plinth
#

the pins button

#

oh wait

#

what is that anyway

shrewd junco
#

Here is the message itself

weak plinth
#

nvm now i really wanna dive into the ngo

#

thanks yall

nocturne vapor
shrewd junco
#

Ah

weak plinth
#

hi guys, begginer question, I have NGO installed, and when i run the game from host it works good, then i join client in, my host has no control he doesnt move at all while client moves freely as supposed, that is happening after i set if(!IsOwner) in the movement update, as if client is owner of his movement script but the host is not owner of his movement script , anyone knows why this is happening? when i remove the if(!IsOwner they both move on both client window and the host window.

drifting plaza
#

I set up a tick system via code not knowing that Unity has a built in system for Netcode, is it okay to continue to use my own system or should I use the built in NetworkManager Tick system?

sharp pawn
#

You can also try asking on Unity NGO's discord, people there are super helpful

sharp pawn
#

it's here

weak plinth
#

i went back to 1.0.2 version and gonna try to follow the codemonkey video on yt to see if it fixes it then il go from there

sharp pawn
#

As said, you can try joining yet another player, maybe this will give some clue. Player movement in multiplayer can be tricky, and once you get to stuff like client prediction and player interpolation... Things get fun ๐Ÿ˜„

weak plinth
#

i do love challenges, it makes u learn, but i hate being stuck on one for too long hahah

sharp pawn
#

It took me quite some time to get my own movement script working in MP. And then a few months later I decided I want physics to work too, so I had to make movement server-side, and than once again was a lot of reworking. But that's a great attitude you have!

#

If you need some help, feel free to DM me. I can't answer 24/7, but maybe I can help with something, from what I've learned myself

weak plinth
#

sure , thanks ๐Ÿ˜„

weak plinth
sharp axle
weak plinth
#

oh and also, clientId:0 is a host right?

sharp axle
#

If you handle everything on the host then you have to deal with lag.

#

and yea. client 0 will always be the host

weak plinth
#

well why is my client becoming id 0

sharp axle
weak plinth
#

nope my bad hes not becoming id0 its just that the host is controling client and client is controling client i believe