#archived-networking

1 messages ยท Page 67 of 1

hallow fractal
#

Ohh that makes sense

high night
#

And they need as photonview

#

That's why you can't have them as childs

hallow fractal
#

Thatns will try and let you know ๐Ÿ˜Š

#

Thanks @high night

#

Need to go take my dog out before the army comes ahahaa

#

What a time

little talon
#

how does one simply set a varable on photon from another script

#

so basicly i have a gun that photon spawns a bullet then tells that bullet who its sender was

#

only problem is that is doesent update on ther clients

#

causing problems in the script

#

i begith of anyone to help

dry pewter
#

hey guys

#

im trying to install pun 2

#

and im getting this error

#

before importing it, the game compiled perfectly fine

#

iv tried importing it multiple times, and it doesnt work

#

any ideas on why?

#

it seems to be a popular error

dry pewter
#

nvm fixed it

hallow fractal
high night
#

@hallow fractal You still have photonview or notworktransfrom on child objects

hallow fractal
#

But in this case as you see, which object needs to have the photon view

#

Child object are the one who are the objects

high night
#

This must be your hierarchy:
Segment0
Segment1
Segment2
Segment3
@hallow fractal

#

No parents

#

NetworkTransform and view on each Segment

#

You should probably deactivate joints and rigidbodies on clients

#

Have them only on server

#

.
Or do this:
Have only one network view for train (the parent you have)
have no network transform
Sync the transform of all segments in the parent with code (photons streams)

hallow fractal
#

But what if one segment has other childs

#

You seen the video i suppose, im really nee at photon, thought i only need to out a photon view on the objects

hallow fractal
#

@high night soo here i have a other scene video, soo the parent (Seg) doset have any photon view on it attached inly these 3 childs that are also the meshs of the train,

high night
#

Object with a photonview cant have a parent
In your case
parent: Seg
object with photon view: Train

#

@hallow fractal

hallow fractal
#

Soo if I get all the child outside the parent does it work

#

Can try

#

No it dont work

high night
#

Whats the new hierarchy

hallow fractal
#

Soo all these were before child of Seg, now i got them out and each have a photon view and transfer view

high night
#

Are you moving them in server?
Or in client with commands
@hallow fractal

hallow fractal
#

No, they the train moves alone

#

It follows the track

high night
#

Train should work now

#

At least transfroms should be synced i mean

hallow fractal
#

It dont, the train moves like its bugged

high night
#

@hallow fractal Is it bugged in server?

hallow fractal
#

The first player that joins the train is all well, but the second player that join the train starts from beginning and it koves like its bugged

high night
#

First player is host/server thats why

#

Here's what i think is happening:

#

On hosts screen, everything is fine train is moved in code and affected by joints
However on client, train is moved by the code, the joints and the network transform

#

And network transform is messing with it

#

because Physics don't go well will direct position sets which is what network transform does

#

@hallow fractal You will need to disable all joints and train-movement code for the train on client
And let the network transform handle it's position

hallow fractal
#

With code?

high night
#

Yes
@hallow fractal

hallow fractal
#

@high night maeby its the assets fault, because now i notice that even i move the train a little bit in front and when i start the game it goes automatically back to its first position

high night
#

@hallow fractal moving on client i assume?

#

second joiner i mean

#

second joiner is cleint

hallow fractal
#

I made a short video to show better, dont lnow how to tell better ahah

high night
#

@hallow fractal
Right now it's expected that client won't be able to move the train
Since i told you to disable client from running that code on train

hallow fractal
#

soo this is what i noticed, the train goes back at the possition, dosent metter where i put th train

#

but i dont know how to make disable that with code, not good at that

high night
#

@hallow fractal This is got to be something to do with train movement code

hallow fractal
#

you think thats the issue why it dont work

high night
#

@hallow fractal I think your code is snapping the train on a spline

#

every frame

#

and it doesn't care about trains initial position

#

or any position

hallow fractal
#

i just send the owner of the asset a message, maeby he know or already did this through photon

high night
#

@hallow fractal You should be just looking into the train moving code

#

It's supposed to be moving the train only with one float variable that spesifies position on the spline

#

And you should sync that value in photon stream

#

@hallow fractal These stuff are not plug and play type of stuff
You need to understand the code to some extend and modify it at your will

hallow fractal
#

if (photonView.IsMine)

#

you mean something like this

#

@high night i know only a little photon coding

high night
#

yeah something like that if you already authorized the object as it should've been

hallow fractal
#

i have found a other way and it works, yes it was the asset fault, but i found a better train and it works just fine

#

@high night

solar garden
#

How do you handle packets ? Do you send a different kind of structure where you call the send method wherever you need it or do you have a single packet structure where you store all requests in a list until you can fire the next packet and cram everything into the packet before sending it kind of like a bus ?

prime nexus
#

Is there any guide about making networked physics-based controlled characters with the new NetCode? Server authoritative but with client-authoritative movement following physics in the owner client, interacting with other similar players (reacting to remote player's physics while not affecting their physics remotely)

jade glacier
#

In any network system, that just come down to deciding input authority vs object authority.

#

if you however give players authority over their own movement, you will have to reconcile sync issues if they can interact with world objects

gleaming prawn
#

People need X many years netcode experience to understand what you said @jade glacier, Lol

#

Tired of answering with a lot of details like you normally do?

jade glacier
#

I just landed in Connecticut after 48 hours of fighting my way home from the tip of South America...

#

So a little at capacity at the moment with life stuff LOL

#

@gleaming prawn

gleaming prawn
#

Oh, got it

#

Hope you're fine

jade glacier
#

Pretty beat up from all of the airports and planes, but better off than most.

#

Glad we didn't get to sea before all of this happened, ships returning from Antarctica are looking like they might get stuck in port. Our ship would have left Tuesday.

rancid anvil
#

How can i call a [command] function by another script?

#

@gleaming prawn

#

That's the score script

#

and I want to call the CmdAddScore by another script in a EnterCollider2D

#

That would be the projectile

gleaming prawn
#

I've never used Mirror

#

You should ask this in their own Discord

#

I'm one of the developers of Photon Quantum, sorry

rancid anvil
#

It is same of Unet

gleaming prawn
#

Never used, sorry

rancid anvil
#

ahh okay

#

thanks you anyway

jade glacier
#

command only works on the local player object that your connection owns

#

has to be on a NetworkBehaviour, and has to be on the root with a NetworkIdentity component

#

That it is named score, leads me to believe you are not putting that script on your player object

lapis valley
#

I'm using Photon Pun, and I don't understand what the Photonview component is, Yes, I know it synchronizes clients with the server, but do I have to add it to everything?

#

For example, for my character do I have to add it to both the capsule (character model) and the camera?

#

(The camera is a child of the capsule)

#

Also, I'm a noob in networking so don't really understand anything at the moment..

high night
#

@lapis valley you dont want to sync camera position in multiplayer

#

camera is supposed to be a locak object

lapis valley
#

Yeah that's what I thought but every prefab spawns with a camera

high night
#

and only one camera needs to present scene

lapis valley
#

or is this not the way to go

high night
#

you will need to deal with that

lapis valley
#

Alright, thanks

gloomy meteor
#

guys anyone here who has experience with photon?

lapis valley
#

Oh, also, how do you set the IsMine variable on the photonview?

#

Or is it done whenever the object is instantiated by the client?

gleaming prawn
#

Later... When using PhotonNetwork.Instantiate

#

AFAIK

lapis valley
#

Yeah that's what I meant by instantiated by the client

#

if that's the case then that's neat

jade glacier
#

IsMine won't be meaningful until after OnJoinedRoom

lapis valley
#

Yeah yeah

jade glacier
#

Typically for net stuff use the OnJoinedRoom instead of Start for stuff

lapis valley
#

So basically I just wanted to know when it gets set

#

so basically after what point do I know that the objects that should be "mine" have the isMine set to true

jade glacier
#

Assume before OnJoined is called, it will be false

#

OnJoined is the answer

#

Can watch for changes with OnChangedAuthority or whatever... don't know off the top of my head without VS code hinting in front of me sorry

gloomy meteor
faint mural
#

It's hard to assert without further info

amber trench
#

lol

gloomy meteor
#

nvm i fixed it lol

#

btw anyone here has any idea how i can implement a timer in photon?

prime nexus
#

@rancid anvil you could make a public function in class Score that just calls CmdAddScore, and make the other script call that public function

#

@jade glacier thanks for the answer, thinking more about it I actually just need to disable physic simulation on remote players (so they are fixed to whatever the servers says like rocks, and only simulate the local player)

jade glacier
#

yeah, that is typical for physics simulations if you aren't resimulating. Only the authority version does physics work - networked clones get moved by their transforms and stay as kinematic.

prime nexus
#

is there an "elegant" way to do it as a setting in NetCode or I just set them as kinematic manually?

jade glacier
#

Never touched netcode, so can't speak to that at all sorry

prime nexus
#

ah no problem thank you, actually is not that hacky anyway

jade glacier
#

its not. Setting non-authority versions to kinematic is the standard for interpolation

#

If you are instead doing a predictive extrapolation you do that with real physics on all clients - but that is a very different animal.

stray scroll
#

@prime nexus You can specify in your ghost authoring component, what components should be for predicted resp interpolated resp server side entity.

#

If you want to use same components but different data, e.g. kinematic on one, dynamic on one, I think you'll need to set up the prefabs yourself and extend the spawning system.

hazy pike
#

in the latest NetCode preview is it possible to sync IBufferElementData components (dynamic buffer) within a Ghost?

desert gale
#

Hi, I really need a unity dev experienced with socket io to help with my networking. I'm willing to pay for help. Can anyone help me?

#

we have all the software built, we're just having a problem when we link to a https site vs http.

lapis valley
#

The call is coming from a PlayerCharacterController and goes to a PlayerCharacterController

#

This is my code:

    //Server (Master client)

    [PunRPC]
    public void S_requestToolPickup(PlayerCharacterController playerPickingUp, Tool tool)
    {
        if (PhotonNetwork.IsMasterClient)
        {
            bool allowToolPickup = true;

            foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Character"))
            {
                foreach (Transform toolObj in obj.GetComponent<PlayerCharacterController>().ToolSet.transform.GetComponentsInChildren<Transform>())
                {
                    if (tool.gameObject == toolObj)
                    {
                        allowToolPickup = false;
                    }
                }

                foreach (Transform toolObj in obj.GetComponent<PlayerCharacterController>().armViewPosition.transform.GetComponentsInChildren<Transform>())
                {
                    if (tool.gameObject == toolObj)
                    {
                        allowToolPickup = false;
                    }
                }
            }

            if (allowToolPickup)
            {
                
                PhotonView photonView = PhotonView.Get(this);
                photonView.RPC("CharacterPickupTool", RpcTarget.All, playerPickingUp, tool);
            }
        }
    }



    // Client

    [PunRPC]
    void CharacterPickupTool(PlayerCharacterController player, Tool tool) {
        tool.gameObject.transform.parent = player.ToolSet.transform;
    }
#

And this is the snippet calling the above function (Also in PlayerCharacterController)

#
    private void handleUse() {
        RaycastHit useRayHit;
        if (Physics.Raycast(cameraTransform.position, cameraTransform.forward, out useRayHit, useRange))
        {
            if (useRayHit.transform.GetComponentInParent<Tool>()) { // We hit a tool - put it in our toolset
                Tool toolHit = useRayHit.transform.GetComponentInParent<Tool>();
                pView.RPC("S_requestToolPickup", RpcTarget.MasterClient, transform.GetComponent<PlayerCharacterController>(), toolHit);
           
            }
        }
    }
#

Any help would be greatly appreciated !

stray scroll
#

@hazy pike no, not that I know of

lapis valley
#

Also, I looked it up and saw that script references cannot be passed into an RPC - so I changed it to Gameobject references and the error still shows up

#

Are you only allowed to send floats/ints/strings to RPCs?

#

Guess I'll try it out

lapis valley
#

New question: Is there any way for a specific client to ignore the automatic scene synchronization for a certain object?

#

For example, I have a character holding a tool, and I want it to move seamlessly for them and have the server handle distribution to everyone else

jade glacier
#

you are referring to the transform sync?

#

Which library?

#

PUN has no server in that sense, just the relay

#

For holding object, you would typically network who is holding it, and network some way of identifying what on that object it is mounted to.

#

@lapis valley

lapis valley
#

Oh my bad

#

Yeah basically objects on my (non-master) client seem to be lagging a lot even though the client is supposed to be "holding" it

jade glacier
#

which would be expected

lapis valley
#

@jade glacier I mean the networking is working perfectly, I just want the client to set the position of the object instead of the server

#

since the client owns the parent object through the "isMine" flag

#

So since the client already has the information of what the transform should be, I would like to override the "automatically sync scene" calls

#

I don't know if what I'm saying makes sense cause I've never done networking before

jade glacier
#

There is no server, so you mean the master client, and that master client has authority?

lapis valley
#

Yeah that's what I mean sorry

#

force of habit

jade glacier
#

You will be fighting the nature of what is going on

lapis valley
#

What does that mean?

jade glacier
#

Best practice is to have the owner tell all non-owners to change its parenting

#

no point syncing the position of a thing that is attached to another thing

lapis valley
#

Yeah that's what I did but it's still changing the position

#

Ohhh

#

Ok, then another problem

#

The reason I'm syncing the position is because the tool can be outside of the player's inventory (I.E. when they die)

#

and I want it to be in the same position on all clients

#

so is it possible to enable/disable position sync?

#

From either master client or non-master

#

So, for instance I'm sending an RPC from client -> server (master client) to request a pickup of an item, and then the master client -> all other clients that the pickup has occured, so in that moment I would unsync position

jade glacier
#

I never use the vanilla stuff, but I would assume disabling that component will stop it from broadcasting

glass goblet
#

anyone know why Server.Start(50, 88888); it throwing an error?

jovial rapids
#

port limit is 65535

glass goblet
#

fixed had it set to private not public

mellow niche
#

Hey guys - not sure if this is the right channel, but has Network Emulation been removed from the editor in 2018.3+? If so, anyone know how to add this back in?

#

Ah damn....reading the docs, it only affected NetworkView & Network, so probably wouldn't have helped. I'm wanting an easy way of testing functionality for WWW / UnityWebRequest / similar in limited connection situations.

harsh dew
mellow niche
#

Cheers - I'm Windows-challenged, unfortunately, so no joy for me. I guess enabling / disabling the network connection is the pragmatic approach.

glass goblet
#

anyone got a network player movement script i could use?

high night
#

find a tutorial and download its code
@glass goblet

glass goblet
#

its finding it tho

high night
#

type pun tutorial in youtube
or unet

most likely you'll see a simple character controller

#

you should be able to unet code for mirror

#

and you should be using mirror instead of unet

#

or pun

glass goblet
#

ok thanks

lapis valley
#

I'm having a weird problem - I used to be able to have two players in the same room but now for some reason they never get put in the same room

#

I created "Room1" on one client

#

and then tried to connect to "Room1" on another, but the second client does not see it

#

Code:

        public override void OnConnectedToMaster()
        {
            Debug.Log("Launcher: Successfully connected to Master");
            

        if (isConnecting)
            {
            // #Critical: The first we try to do is to join a potential existing room. If there is, good, else, we'll be called back with OnJoinRandomFailed()
                PhotonNetwork.JoinRoom("Room1");
                isConnecting = false;
            }
         }

        public override void OnDisconnected(DisconnectCause cause) // We dont have internet or PUN servers are down
        {
            Debug.LogWarningFormat("Launcher: Disconnected from Master");
        }

        public override void OnJoinRoomFailed(short returnCode, string message)
        {
            Debug.Log("The server is not up, starting server");
            PhotonNetwork.CreateRoom("Room1", new RoomOptions { MaxPlayers = maxPlayers });
        }
#

The problem is that it was working perfectly fine before and is acting up now

#

Debug.Log(PhotonNetwork.CountOfPlayersInRooms); returns 0 even when another person is online

#

Should I just switch to mirror? I've heard that it's way more consistent than PUN

static schooner
#

hey guys im trying to make a multiplayer game for my first time using photon, i got everything ready i got player movement but when i try to add a camera to the player prefab and play the game, the second player that joins the game uses the first player camera

lapis valley
#

Well, you don't really need to have a camera on the playerprefab cause you will only have one camera per player

#

What I did for my game is that I had a single camera that is added to whichever prefab has the "isMine" flag set to true on its photonView

static schooner
#

hm

lapis valley
#

Probably not the best way to do it

static schooner
#

im quite new to unity and c# can u explain a bit more

lapis valley
#

So basically, you have a single camera in your hierarchy, and when you instantiate an object using Photon, change the camera's parent to the object you instantiated

static schooner
#

hmm

#

im gonna try that

lapis valley
#

Because the client doesn't really need to know the position of all of the other players' cameras

#

Unless your game depends on it

static schooner
#

is an fps game

#

well it will be i hope

lapis valley
#

Yeah so not having to update the positions of other players' cameras will actually remove some of the overhead

static schooner
#

should i do all of the camera code where i instantiate the player?

#

and i think the camera should be disabled as well and then set it as active

lapis valley
#

You don't have to, it all depends on what you want to do for your game

static schooner
#

hmm

#

i figured smth else

#

what if i instantiate a camera for every player?

lapis valley
#

Then you're gonna have to set the correct one to display to every player

static schooner
#

i think i did it(not instantiating)

#

i hope it works

#

if not im gonna go back to instantiating

#

noup ๐Ÿ˜ฆ

jade glacier
#

haven't read all above, but set the region in settings when developing to ensure all clients and the editor end up in the same region

#

the next PUN2 release has Dev Region added that uses a specified region for development builds and the editor, and gets ignored for production builds. @lapis valley

lapis valley
#

How would you set the region?

spring crane
#

Same file you set your AppID IIRC

jade glacier
#

in the the PUN settings @lapis valley

hallow fractal
#

Hello, can someone help me on this issue, soo i have a train in my game and that has a photonview and photon transform view on it, soo when the player joins everything is fine but when the master leaves the room than the train acts weird to the other player on the room

#

Whats the problem?

jade glacier
#

I would try to debug what is happening with the ownership of the object.

#

But there will be a period of confusion with the vanilla components as ownership gets passed over to the new Master, assuming that is happening at all.

hallow fractal
#

Hmm

#

The train just follows the track, and when the masters leave the train goes off the treck and acts no normally

#

For example i have a object on the scene, it has only a rotation script, and when thr master leavs everything is fine

jade glacier
#

Might be extrapolating on clients due to no more incoming updates

#

the vanilla transform syncs are pretty terrible

#

I am part of the Exit team and my project right now is an extension system for all of that

#

So you are welcome to try out the SyncTransform component in the extension library. Its based on my Asset Store asset that fixes a lot of this stuff. @hallow fractal

weak plinth
#

hi guys ^^ does anyone have a video tutorial for a multiplayer game for the latest version of unity?

jade glacier
#

not that I know of, but if there are any you should be able to find it with a search on youtube.

#

NetCode is quickly shifting sand, so no idea how current things would be.

weak plinth
#

ah ok

#

thanks ^^

hallow fractal
#

@jade glacier will look at this when i get my project beck up, literally the worst thing happened, i tested the project and it stoped, so i closed it through task manager amd when i open the project back up everything is messed up

jade glacier
#

Unity projects are pretty resilient. If you just delete everything but the assets folder and project settings, it should rebuild itself.

#

And GIT.

mint cedar
#

(first time asking for help, hope i did nothing wrong; friend recorded this btw)

so this is the issue im having, if im hosting the game i can move around freely, but once my friend joins i get teleported back to where he spawns, and i cant move the camera. both of the players move around but not by themselves. its really hard to explain but once you actually play it you know whats happening. this is a big issue with my project and i cant figure out whats going on. can ANYONE here help me with this? im using Mirror as my multiplayer framework. thanks.

gray pond
#

@mint cedar Mirror has its own Discord for support - you'll get better answers there.

mint cedar
#

oh thank you i will repost there!

hallow fractal
#

@jade glacier well it was photons fault

jade glacier
#

oh?

hallow fractal
#

Yeah, i had a back up folder of the project, and after importing step by step files from the corrupted project and testing them in multiplayer i noticed that when i imported a project that had a photon view on it was the cause of the trouble, i dont know why but when i played multiplayer and when that object was on my master controller also controlled the other players but on its perspective,

#

Maybe both objects had the same id or dont know

#

But all that happened after my project stoped working and i had to use task manager to close it

jade glacier
#

PUN2 broke things, or SNS?

#

That doesn't sound so much broken, as just something is set right in code or the inspector.

#

Can't really say though, not much to go on there.

jade glacier
#

stopped working like you are describing indicates an endless loop

hallow fractal
#

@jade glacier no stop working, but the players acted weird in the scene when they joined the room, i couldn't figure out the issue till i imported each object step by step to a new project

empty yew
#

Is there PUN2 help here?

jade glacier
#

Best to just ask a question

#

But yes, there are PUN2 users/devs here on and off

empty yew
#

I'm just barely trying to set up multiplayer. I have them connect to Master, that works. I have them join a room, and if it fails, it gets created then they try to join again.

The big issue is that when testing two instances of the game, the player count only shows 1 on both.

spring crane
#

Make sure nicknames are unique and you have set it to fixed region

empty yew
#

I've not touched nicknames, or region setting

jade glacier
#

you will want to touch the region setting to be sure your editor and built games end up in the same region

#

The next PUN release has a Dev Region, but for now setting Fixed Region is the way to go get around that happening

empty yew
#

Are you able to describe where I can set that in the editor, or is it through code

jade glacier
#

Have you run the tutorials yet?

empty yew
#

I was watching one on youtube. I figured after watching a portion of them, I'd be able to simply have two players in a room

jade glacier
#

Do the getting started tutorial first, or you are going to be stuck a lot

empty yew
#

Alright. thanks @jade glacier

dapper night
#

Hello Everyone,
it's a very basic questions but strangly i cant find any tutorial or course explaining it.
i read some scripts from unity's new Dots Netcode, but im having difficulties to understand the principles behind Clients & Server Ticks.
from what i understood, Clients and Server are running simulations, the server is sending snapshots for every tick (amount of time) and clients are doing the same but also trying to fix wrong simulations for all Client Side predictions.

  1. how clients and server sync their Ticks ?
  2. what is garanting that all clients are running into the same Tick and not running into individual Ticks ?
    Thanks!
jade glacier
#

Its beyond bleeding edge, so its going to be very hard to find anything solid

#

The DOTS channel though will likely have some advice

empty yew
#

I set the region and it works now. I'm gonna double thanks @jade glacier

floral turtle
#

has anyone here used Zapnet? Looked through the documentation, it looks really programmer friendly, minimalist and well structured. Downsides are no open source + definitely not battle tested, but curious if anyone has had any experience with it.

#

semi-related: I've done several multiplayer projects, but nothing super long-term or robustโ€”does anyone have any strong feelings about loosely coupled networking systems? Stuff like Unity's HLAPI is very, very tightly coupled, so I'm curious if anyone has worked with any packages that are the opposite. I'm a huge fan of stuff like facade pattern to promote iterative development, but networking packages can seem pretty daunting

weak plinth
#

zapnet is not bad and you can get source access upon request, but photon bolt is better and battle tested so i'd go with that or just wait for new networking assets (or wait for zapnet to add missing features)

stray scroll
#

@dapper night Clients send command to server and not snapshots.
You can choose to have fixed tick or not on client.

  1. They don't run tick at same time, Server runs tick, then client predicts when it should runt he same tick. The tick we should run is calculated from
                                  ((uint) estimatedRTT * (uint) tickRate.SimulationTickRate + 999) / 1000;

from NetworkTimeSystem. You should check out the Client & ServerSimulationSystemGroups for how the update works.

dapper night
#

ill try to read it again and ask here in case something is not enough clear to me ๐Ÿ™‚
Thanks

stray scroll
#

[Generic Mutliplayer question, using DOTS NetCode] So, I'm starting to move into the phase of implementing my projectiles and how to handle them. My game consists of fast moving spaceships that are controlled by players. Now you'll be able to shoot from pilot seat, forward, and monitors controlling rotating guns on the shipsurface as crewmembers.

So I haven't really set up the limitations yet of how many projectiles/etc can exist in the game. But as start generally maybe there are 4 forward guns, 5 off guns, x 8 ships, with fire rate of 2/sec? Networked entitiy, Raycast + start end vs trigger collider? Local entity with some sync values?

jade glacier
#

The architecture I assume is snapshot interp with server auth?

stray scroll
#

Yes

jade glacier
#

The main thing you will be dealing with is deciding how to gloss over the timeframe differences between players and the server

#

if you want tp predict the guns firing on the shooters side, those will be decidedly out of sync with reality

#

So you get into the questions of server rewind vs cheating reality on the clients

#

I would strongly suggest making a very basic testing scene for getting your head around how you plan to cheat this stuff

#

having players mounted to other player controlled objects, shooting projectiles that originate from that other players object, but a triggered in the players timeframe.... involves a lot of timeywhimey

#

For slower projectiles I typically cheated them on the shooters side. As in I would try to induce as much latency as possible before feeling icky first... then also reduce the initial velocity on the shooters side... so that projectiles would converge with the world timeframe. Player fires... projectile spawns and starts moving... 50-100ms later server says "you fired" and you then start tracking where the projectile would be based on that, and lerp your current cosmetic projectile into agreement @stray scroll

stray scroll
#

Hmm

jade glacier
#

You can also cheat it a bit if proximities aren't close by having the projectile on the server originate already X ms into flight

harsh dew
#

Are you using projectiles or raycasts?

jade glacier
#

Basically cheating the server projectile into the players timeframe a bit more

#

this is just for slower moving projectiles yeah.

#

for hitscan, you likely just go client auth or server with with rewind

stray scroll
#

I guess simplest would be to do some pre animation that concludes into the server doing the shot.

jade glacier
#

I assume you are using a collection of weapons so some slow movers and some hitscans

#

yeah, if you can get away with full server auth and no client prediction, things get way easier

stray scroll
#

But might feel to unresponsive.

jade glacier
#

But that does make aiming kind of hellish if its a point and shoot thing

stray scroll
#

The thing is my spaceships are flying really fast rn, so the projectiles has to be really fast as well, so they could really be raycasts with a start+endpoint for visuals.

jade glacier
#

The upside is everyone sees reality, with no weirdness

harsh dew
#

Raycasts are a lot easier since you can just shoot your vfx on the tick that the thing actually fired

jade glacier
#

raycasts if you predict though require either server rewind or client authority

#

So they aren't without downsides

stray scroll
#

Hmm yeah, so I would need to put back the states of the ships and check if hit right?

jade glacier
#

Unless again you opt for no prediction

#

yeah, for bullethell its not recommended

#

its fine for like CS where the number of bang bangs is limited

stray scroll
#

Hmm, I like my bang bangs

jade glacier
#

but those rewinds will really start to add up in a shitstorm

stray scroll
#

Thanks, I'll try with no prediction and some animation to start, then predict with client correction.

jade glacier
#

If you are server auth, it all starts there yeah

#

see how bad things are with no prediction, and then work in the cheats

spring crane
#

Alternatively, do client auth and wait for the cheats ๐Ÿ˜Ž

jade glacier
#

Client auth has all kinds of other downsides in fast shooters, like the illusion of them shooting at where you were rather than where you are becomes more obvious

hallow fractal
#

@jade glacier you have an asset about sych?

jade glacier
#

a transform and animator sync extension for some of the middle layer networking libs yeah

#

having some syncing headaches?

#

@hallow fractal

hallow fractal
#

You remember my train issue? Now that my train get sych i have another problem im facing ๐Ÿ˜…, soo when two players enter the train and become child of the train both of the players dont get the same position well sych, what i mean is from one players perspective the other player is outside the train like its flying

#

But this happens only when i enter the train

jade glacier
#

Are you syncing their positions based on transform.localPosition? and you are syncing their parenting?

#

Which library are you using again?

hallow fractal
#

Hmm so im using pun2, both player have photon view with photon transform view and animator view on it attached, the train has only photon view with transform view on it

#

No, the trains mother has photonview and the childs have photonview and transform view

#

Soo these are my setup

jade glacier
#

You can give the Extensions I am making for PUN a try, they do try to address a bunch of that.

#

They are Beta, but they are official Exit stuff that will eventually be part of PUN2.

hallow fractal
#

Extensions you mean your asset

jade glacier
#

They handle it with mounts that index things netobjs can be children off, and the parent id is synced on the same ticks as localposition/rotation

#

There is my store asset which is just the Transform/Animator sync - not that

#

the extensions are the work I am doing for Exit to give PUN2 better components, syncvars etc

hallow fractal
#

I will make a video and maeby you will see the whole picture of my issue, than tell me if your asset can help me on thag, is that ok?

jade glacier
#

If its not an impossible paradox you are dealing with, it can be dealt with

#

A video can't hurt, sure

#

The issue with all of this stuff is dealing with ownership, and the latencies involved that create state disagreements in client prediction

hallow fractal
#

For me that im dealing with objects sych for the fitst time its a little hard ๐Ÿ˜…, will send the video later on

jade glacier
#

So there are some unsolvable issues, like if you hop on and off a train that you don't own, others will see you teleport a bit as you move between time frames

#

nested netobjs is kind of the deep end of networking

#

you are very much in the thick end of the time paradoxes you have to deal with.

mighty snow
#

does unity networking system use C# to code
?
like to code a server side for a mulitplayer game, is it written in C#?

stray scroll
#

@mighty snow Are you talking about the new DOTS Netcode ?

mighty snow
#

ugh no

stray scroll
#

Then be more precise

mighty snow
#

iam new to unity so

#

iam saying what ik rn

stray scroll
#

So the old networking solution "UNET" is deprecated, so you shouldn't use it. You could use MIRROR which is a fork of it, downloadable from assetStore. You can also use Photon, which is 3d party solution, which I think is most popular. Then there is the preview very early DOTS NetCode which you can try out if you're using DOTS ECS.

mighty snow
#

well ye lets skip the DOTS thing

#

so if i want to use photon to create a multiplayer game for example, am i gonna write the whole game in C#? or do i have to use another language for the photon networking

#

or mirror

stray scroll
#

If I'm not mistaken Mirror and Photon both don't use a client-server architecture, but you can use one client as server if you want to. So all logic, you'll write in C# if you want.

mighty snow
#

does that mean that the game will be client sided?

stray scroll
#

Photon PUN uses master client.

#

Really you could make two fast googlings and get info for this

rancid anvil
#

What could the error be there?

gleaming prawn
#

you can use Photon Bolt @mighty snow

#

Which is a production-ready (and battle tested) pure client-server architecture (with full server authority).

#

Both client and server are unity instances, so all C#

#

If you go for more basic photon realtime, you can also write server logic (to run on photon servers, no Unity APIs) in C# (photon server plugins)

mighty snow
#

so all iam gonna use is C#

jade glacier
#

All of the options discussed so far are c# yeah.

gleaming prawn
#

Yes, unless you want to insist in using C/C++... In all these options you can call native code anyway...:)

spring crane
#

@stray scroll Mirror is classic server-client

rancid anvil
#

Why objects seems losing their authority when another object get spawned?

#

Trying to send command for object without authority. ChatSystem.CmdSendMessage
UnityEngine.Debug:LogWarning(Object)

jade glacier
#

Are you starting it as local player?

#

Which lib? @rancid anvil

rancid anvil
#

Yeah

#

Mirror

#

@jade glacier

jade glacier
#

Check how you are spawning those

#

You can only have one local player object

#

Any number of authority objects

#

But only one is your local player

#

The mirror discord server can help you with that

rancid anvil
#

Yeah but when i spawn another player , the one i spawned before lose his authority

jade glacier
#

Yeah, how are you speaking it?

rancid anvil
jade glacier
#

Losing authority? Or just changing local player

rancid anvil
#

As you see It starts with OnStartAuthority

jade glacier
#

Islocalplayer is not the same as hasAuthority

#

I'm on a small phone

#

So can't read text in screenshots sorry

rancid anvil
#

is there a way to change the starting function from OnStartAuthority to something simply like OnStart , or local player

#

Because i think that's the bug

jade glacier
#

You can only send command through your local player object.

rancid anvil
#

Yeah

#

How can i send them even if its not

jade glacier
#

With messagebase

#

Command sucks like that.

#

The local player object model sucks like that. Just send messages.

#

Otherwise you end up with 100 components on your player object

rancid anvil
#

So what will you suggest me

jade glacier
#

Messages

#

And hitting up the mirror channel for details

#

They keep changing the message layer, so I have no idea what the current methods are.

vivid owl
#

is using gRPC w/ Unity recommended?

brittle plinth
#

Can anyone direct me towards a proper networking tutorial in Photon Bolt using authoritative architecture? Preferably a shooter, thank you!

jade glacier
#

Photon Bolt is inherently server auth - so just the standard tutorial. It is an FPS example no?

brittle plinth
#

The Advanced Tutorial is an FPS example yeah. But tbh, didn't really understand it so was hoping for a tutorial(as in a vid)

jade glacier
#

Someone out there may have made one.

#

But generally companies who build this stuff DO NOT want to make vids. They are time consuming to make, generally a bad way to learn, but mostly they are impossible to change as minor library changes are made - so the videos are constantly out of date.

#

If you want to get into networking, I would let go of any hopes for hand holding. Networking is hard, even with the best tools.

amber trench
#

@vivid owl really depends what your objectives are

weak lava
#

Hi, how would a proper game server loop looks like ? more specific id like to create a tick based system for sending / receiving data but I'm not quite sure. I've written some pseudo code ```cs
var sw = new Stopwatch();
sw.Start();
while (running)
{
var begin = sw.ElapsedMilliseconds;
//receive
//update stuff
//send
var elapsed = sw.ElapsedMilliseconds - begin;

            if (elapsed < hz)
            {
                Thread.Sleep(hz - elapsed);
            }
        }``` i appreciate any help/hint.
jade glacier
#

Tick based usually implies doing something on a fixed timing, and that usually for Unity is best if its based on FixedUpdate()

#

Unless you have NO usage of FixedUpdate() as part of your simulation

weak lava
#

Well its not in Unity.

jade glacier
#

Ahh, then sure

halcyon ermine
#

Just learning some networking (PUN 2) and I am having difficulty spawning a player death particle effect. The effect spawns and appears fine to the opponent however when the killed player rejoins (they are kicked when they die, in lue of proper respawns just yet) the effect is spawned again and I believe only the killed player sees it. I have a code sample (below), I am using PhotonNetwork.InstantiateSceneObject() and have a timer to wait and then destroy it once the particles have finished. Would anyone be able to help me sort this out? Thanks very much!

Code:

jade glacier
#

Easier answer is to pool the death effect and not make it part of the player object

#

Though that may not be what you are after. If you are not networking it as an event like an RPC - no one else will know abou tit.

#

And why are they kicked when they die?

#

Kicked as in literally the player is forced out of the room?

halcyon ermine
#

Yes kicked from the room. Following a tutorial

#

Thank you admins for your assistance!

jade glacier
#

The admins don't actually speak here much or at all

halcyon ermine
#

AskAlice helped get me unblocked I beleive

jade glacier
#

Oh, for that

halcyon ermine
#

Tried to post the code to show you what I have so far and it blocked me

jade glacier
#

Sounds like way too much code then ๐Ÿ˜›

halcyon ermine
#

You mentioned using an RPC, I've only done that once so far, the examples Ive been able to find are not very clear

jade glacier
#

I would make your death effect not part of the player object if you are wanting it to stick around after the player departs.

halcyon ermine
#

Not really, I just fat fingered pasting it and I think the system took it as spam haha

#

Ok, so who should be responsible for spawning it? the game manager?

jade glacier
#

Each client, when they get the "I just died" RPC

#

specifically make a component on the player object itself

#

that detects the death, and have that spawn a pooled death "poof" or whatever you are doing there.

halcyon ermine
#

Ok, so the player still does the spawning, just through a special component, and through an RPC?

jade glacier
#

Sure

#

No hard correct answer. Just sounds like you want the "poof" to exist after the player object is destroyed, so that would be a way.

halcyon ermine
#

Yes, so that the rest of the player's see it

#

Thank you, I will run with that and see what I can do

jade glacier
#

You don't need an RPC for that btw

halcyon ermine
#

Oh?

jade glacier
#

just have your player OnDestroy trigger it

#

but that might cause a weird delay if its depending on a complete disconnect

#

so either an RPC, or really triggering it on whatever triggers your death animation if you have one.

halcyon ermine
#

Right now it spawns it, it starts a coroutine to wait 0.25 seconds, then the player leaves the room, and aafter the 0.25s it calls a PhotonNetwork.Destroy

jade glacier
#

Your animator could trigger it as well

#

Sounds messy

halcyon ermine
#

Perhaps, I'm just learning so it will probably be messy until I get some practice ๐Ÿ™‚

jade glacier
#

I would STRONGLY recommend against learning Unity by doing a networked game

#

Have you completed a single player game?

halcyon ermine
#

Im not new to unity or coding

jade glacier
#

Ah, nm then

halcyon ermine
#

Just new to PUN / networking

jade glacier
#

Gotcha

#

If you have something already being sent as part of your death that you can latch onto, use that.. like when your timer expires if that is the trigger... go with that.

halcyon ermine
#

I understand the basic premise of views and syncing and view ownership, just the exact code to do some things eludes me

jade glacier
#

Making extra senseless messages will bite you later.

halcyon ermine
#

I have an OnDie function already, I simply did the Instantiate call then the LeaveRoom, thats it. I later added the timer thinking that would help, it hasnt

jade glacier
#

Once you start throwing around coroutines, you are on a path to misery IMO

#

avoid them like death itself

#

Not sure what you are trying to make happen, but anything that is meant to linger and finish out its life, should probably a pooled or instantiated object that has its own built in death timer.

halcyon ermine
#

How would I, over a networked space, find the end of a particle effect that is instantiated and then destroy it when its done?

jade glacier
#

I don't see the reason for networking being involved in that?

#

Effects are not something you networking typically

#

they are "Effects"

#

you want to network "causes"

halcyon ermine
#

Well it is. Something has to spawn it and all clients have to see it, right?

jade glacier
#

You just networking "Player died"... and that is it

#

the rest each client does on its own after that, since its deterministic in nature

#

Reduce all thinking in networking to What is Cause? What is Effect?

#

Which also turns into normal networking speak "Inputs" and "States"

halcyon ermine
#

It is a particle effect, I understand cause vs effect, I said effect because this is a particle effect

jade glacier
#

You want to avoid serializing the outcomes when the input is all that is needed.

#

What does the particle effect though have to do with causation of anything though?

#

The player dies... that is the cause no?

#

Player dies.... series of things happen after that

#

That series of things is deterministic

#

the clients don't need to be told each thing that happens after that, they just need to be told "Kill player X"

#

the rest is all just a timed set of events on the client

halcyon ermine
#

They need to see the particle effect

#

its a visual confirmation of the kill to all the other players

jade glacier
#

yeah, so spawn that as part of the response to "You Dead"

#

I'm not sure you are following me here

#

I shoot you... you register that and tel all players "He Got Me... I am dead"

#

That is the only event needed

#

Every client now knows that you are dying for good....

#

So they start the death animation... then despawn your body... then show particles... or whatever

#

There is no reason to sync all of the stuff that happens to your corpse. And its problematic trying to anyway.

halcyon ermine
#

How do you then explain/achomplish ragdolls? There are tons of games where some guy gets blown up and tossed and we all laugh at his body ragdolling all over the place.

jade glacier
#

that is typically done locally

#

But you can network that state if its still important

#

and then once the body comes to rest the owner says "Ok I am done dying now"

#

and THAT starts the decomposition process or whatever

forest dove
#

So in Unity multiplayer, how does the game tell who's the enemy and who's the player? Could tags be used to differentiate the two?

vivid owl
#

@amber trench building a turn-based game

stray scroll
#

@forest dove UNET or DOTS NetCode?

forest dove
#

I don't know?

jade glacier
#

He is asking which lib you are using

forest dove
#

I just use whatever Unity uses

#

Right now, I'm still learning Unity, but I want to know how multiplayer works so that I format my game in a correct way that if I wanted to transform it into a multiplayer game, I already have the code in place to do so

#

And more importantly, it would be important to know how to tell the raycast system to ignore the player, but not enemy players

stray scroll
#

@forest dove The thing is that unity deprecated their old system called UNET, and their new system DOTS NetCode is for when using their new Entity Component System.

#

So if you're learning unity, you shouldn't use any of them. And I don't think it would we wise to start of with a multiplayer game when learning unity.

forest dove
#

I get you man, but I want to tell my Raycasts (for the gun script) to not hit the player, but I'm concerned layercast will not work in a multiplayer sense as it may also think the opponent is also the player, which would be bad

gleaming prawn
#

I think you should really read what Jaws said: do NOT start with a multiplayer game...:)

#

People will not even answer to you here, because the questions will not make much sense. Please take your time, learn to program with Unity, finish a few fun single player games first.

forest dove
#

Ok

rancid anvil
#

They all two have ClientAuthority
But i still get the error
why

#
        //ASSIGN PLAYER AUTHORITY
p = transform.GetComponent<PlayerScript>();
p.GetComponent<NetworkIdentity().AssignClientAuthority(this.GetComponent<NetworkIdentity>().connectionToClient);

        CmdSendMessage(message);
        inputField.text = string.Empty;
p.GetComponent<NetworkIdentity().RemoveClientAuthority(this.GetComponent<NetworkIdentity>().connectionToClient);
    }

#

I also tried giving authority

gray pond
#

Answered in Mirror's discord. ^

jade glacier
#

I assume it was a case of confusing authority with localPlayer

amber trench
#

@vivid owl for turn based games, almost any decision at that level of abstract will be a good one, as long as you're comfortable with it. you will probably have the most luck using something like Google Play Game Services

#

unless you are making a massively multiplayer turn based game or something that will be an esports game, the exact pattern and constraints of GPGS is really good

vivid owl
#

I don't want a lock-in

#

we do have some MMO aspects

#

but in terms of networking, my project is more closer to a turn-based arena

amber trench
vivid owl
#

don't think I need a real time networking

amber trench
#

and depending what skill level you are at with devops

#

hmm

#

i really think GPGS is going to be your speed

#

if you need something that says "turn based" in its feature list, you're looking at a commercially hosted solution

#

GPGS is free

vivid owl
#

I think I'm pretty skilled at devops

#

currently, running a k8s cluster

amber trench
#

you should probably take a look at MagicOnion then, it is authored by a very thoughtful and experienced developer

#

a little bit more carefully

#

you are going to have a bad user experience with a purely one-way communications concept

#

if that is what you're looking for, the most pure definition of "not real time"

#

you're just going to wind up polling, and what would be the point of that

#

every fully open source framework will advertise itself as real time

#

i have had a positive experience using just SignalR too, if that is more your speed (asp net core)

#

it Just Works, but neuecc already "fixed" everything with signalr for games

#

in magic onion

vivid owl
#

hmm

amber trench
#

the only games that do not do polling use push notifications to tell the client when to poll, which to me seems basically just as bad

#

a lot harder to test, etc.

vivid owl
#

also, we already have a pretty large amount of backend written in Go already

#

currently relying on HTTP and websockets

amber trench
#

if you are already familiar with protoc, you will have a fine time using it to generate code for unity

#

you will be reinventing a lot of a wheel here

#

which is okay

#

JSON.Net / Newtonsoft.JSON works fine in unity too, and depending on what you want to do, having a JObject in addition to strongly-typed casted objects may be more useful to you

#

there does not exist an swagger/openapi-like generator for UnityWebRequest

#

windows unitywebrequest doesn't even support gzip

#

you have to decompress it yourself

#

i don't believe UnityWebRequest supports HTTP/2

#

so generally, i'm just saying, you're walking into a relatively immature platform compared to what you're used to building web apps

#

i don't know if go's websockets whatever (is it gorilla?) will even let you set the headers that websocketsharp needs

#

for compressed frames

#

is this helpful @vivid owl ?

vivid owl
#

I see

#

this was quite helpful, I'll be discussing this with the rest of the team

amber trench
#

cool

#

yes personally i have had a lot of success with WebSockets

#

i use java as a backend, but it sort of doesn't matter

#

if you are writing something from scratch, i would strongly suggest going pure csharp

#

if you're turning a web-based game / experience into unity3d

#

you will probably have the best time continuing to use JSON

#

and not trying to innovate there

#

you will have a bad time doing automatic reconnection on ios / android

#

lots of stuff to learn

undone sigil
#

@amber trench i think that UnityWebRequest is just a wrapper over curl which does support HTTP/2

gloomy meteor
#

guys

#

i want the animations to play over the network but not for me what do i do?

gleaming prawn
#

what is the network SDK you are using?

amber trench
#

@undone sigil libcurl also supports gzip, and yet

frozen canopy
#

Hello there, i'm making a Snake 3D Online game, when i try to implement the Multiplayer side, it gets everything really weird. The snake has the joystick and button on its prefab, and OnStart it assigns that joystick and button from his parent so it should not get weird, i can pay someone if can solve this im really desesperated.

#

Please ๐Ÿ˜ฆ

vivid owl
#

I'm having trouble getting gRPC to work with IL2CPP

weak plinth
#

Just what is going on with the UNet depreciation stuff? I have been googling but all stuff that I have seen is outdated by years. What is the new system? Should I wait for the new system?
I'm new to Unity and I'm trying to make a multiplayer (<10 players per session) game as my first project to get some actual practice. But seems like a lot of things is going on in the networking section.

jade glacier
#

Your first project should just be for learning networking concepts anyway

#

I wouldn't try to pick "the perfect" engine

#

Do tutorials for Bolt, PUN, Mirror and NetCode if you want to get bleeding edge.

weak plinth
#

Isn't Unity NetCode under development?

jade glacier
#

Do you mean is it a beta preview?

#

Yes, will be for quite a while.

weak plinth
#

Daaaamn

#

So until then I should either stick with UNet (which sounds plausible for a new developer like me but its getting depreciated soon so Ill need to stick with a more future-proof plan) or the ones you recommeneded

#

Thank you

#

TBH I'm not really familiar with networking because I was a Roblox developer and all those networking was done by the Roblox developers

odd elm
#

I'd definitely use Bolt PUN or Mirror over Unet

#

Mirror is basically a 3rd party clone of Unet

#

(that's not abandoned)

weak plinth
#

Which should I use, PUN or Mirror?

#

They both look fine

odd elm
#

if you want a backend managed by someone else (with a cost), probably PUN

#

if you want to host everything yourself, probably Mirror

weak plinth
#

I see

#

if you want to host everything yourself, probably Mirror
Meaning I host my own dedicated server?

odd elm
#

yeah, and do all your own matchmaking and stuff

weak plinth
#

Okay

#

Thank you

#

Then what is steamworks?

odd elm
#

steam integration

weak plinth
#

So I'll sell (or upload) my game on steam with steamworks

#

And perhaps add an achievement or two

odd elm
#

yeh, that kind of thing

#

possibly server browsers? not sure

weak plinth
#

Not really

#

I guess valve have their own servers

#

What about the "join friend" feature on steam?

odd elm
#

sorry i haven't used it, i assume that could be done through it

weak plinth
#

Okay

#

That's fine

#

Thank you again

odd elm
weak plinth
#

:3

gleaming prawn
#

Looking For: One experienced Unity (C#) programmer ----- but offering no salary (future share split)
This is mutual exclusion right there.

stray scroll
#

At least it's not a 4 year project ๐Ÿ˜›

gleaming prawn
#

Yes, it's somehow valid because he's very honest about the scope: prototype for kickstarter pitch...:)

prime nexus
#

If you want to use same components but different data, e.g. kinematic on one, dynamic on one, I think you'll need to set up the prefabs yourself and extend the spawning system.
@stray scroll thanks for the response didn't see it before. Extend the spawning system? Can't I check within a script if the given instance is the local player or remote one, and in the case is remote client then set as kinematic?

stray scroll
#

@prime nexus Sure, that would basically be the same thing, just possibly less control on when it happens.

prime nexus
#

๐Ÿ‘

#

I see is done in the multiplayer example too, but the script doesn't seem to be referenced anywhere (or I am missing something)

#

the documentation about this seems lacking

#

so what's the flow? You create a class like the one in the example and...

stray scroll
#

@prime nexus Bootstrap is from Entities package, so it checks for the most descendant script of the original bootstrap, and calls it

prime nexus
#

Cool!

ocean talon
#

Where do I ask questions

prime nexus
#

Thanks Jaws

stray scroll
#

@ocean talon depends what your question is about, generally in the channel as category of which your question fits in.

rancid anvil
#

Why even if i get the player component it give me error

#

Object reference not set to an instance of an object

weak plinth
#

Next time when you ask for help, remember to post 50 lines of the most relevant code and the full error message. @rancid anvil

#

Well here brings my (potentially stupid) question
To make a multiplayer game
If all objects can be seen by the clients
do they (or their ancestors) need a NetworkIdentity?

gloomy meteor
#

hey if i am calling a death animation in unity how do i call it?

weak plinth
gloomy meteor
#

no i dont want to know about code with animations

weak plinth
#

oh

gloomy meteor
#

i am asking like if i want to play a death animation in photon

#

i dont want the player to be controllable while the animation is playing

#

so would i destroy and then play the animation(does'nt look possible)

#

can someone help me with that please?

rancid anvil
#

@weak plinth

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro; //TEXT MESH PRO
using Mirror;
public class ProjectileScript : NetworkBehaviour
{
    
    [Header("Projectile Settings")]
    public float projectileSpeed = 10.0f;
    public float projectileDamage = 5.0f;
    [Tooltip("Projectile timeout in seconds.")]
    public float timeout = 5.0f;


    PlayerScript p;
    PlayerScript s;

    

    void Start()
    {
        Destroy(gameObject, timeout);

    }


    // Update is called once per frame
    void Update()
    {
        //ONLY SERVER CAN MOVE PROJECTILE!
        //This prevents hackers from executing injection to make bullets change value like damage and speed.
        if (!isServer)
        {
            return;
        }

        ProjectileMovement();


    }

    [Server]
    void ProjectileMovement()
    {
        //later we can add special movement effects and maybe trails
        transform.position += (transform.up * projectileSpeed * Time.deltaTime);
    }



    [ServerCallback]
    void OnTriggerEnter2D(Collider2D col){
        if (col.gameObject.tag == "Player"){

            
            
            p = col.transform.GetComponent<PlayerScript>();
            p.TakeDamage(projectileDamage);
            s = GetComponent<PlayerScript>();
Line 62     s.AddScore(10);
            //ADD SCORE IF YOU HIT
            

            Debug.Log("You hitted a player");
            //Destroy the projectile
            Destroy(gameObject);
        }
    }
}
#

NullReferenceException: Object reference not set to an instance of an object
ProjectileScript.OnTriggerEnter2D (UnityEngine.Collider2D col) (at Assets/Scripts/ProjectileScript.cs:62)

harsh dew
#

Why would your bullet have a PlayerScript?

#

And what does s mean or p?

gloomy meteor
#

hey plz help me out

bitter flame
#

hey is UnityWebRequest for Android correct here?

rancid anvil
#

@harsh dew 1 for health bar
2 for score

#

and

#

The p is the collider get component of the player

bitter flame
#

@rancid anvil just check if Bullet hit player for Healt and parent the bullet to the Player to check who shot

rancid anvil
#

s is just the get component of the player

gloomy meteor
#

heyyy!!

#

please someone

#

nah leave it ill figure it out lol

bitter flame
#

pls dont spamm

#

maybe just ignor player controlls in that moment and then play the anim?

gloomy meteor
#

yea thats exactly what i was thinking

rancid anvil
#

@bitter flame How could i parent it to the player who shot

bitter flame
#

Bullet.transform.parent = Shooter.Transform

#

or if the gun is child of shooter

rancid anvil
#

wait

bitter flame
#

Bullet.transform.parent = Gun.Transform.parent

rancid anvil
#

cant I make something like a transform

#

In ProjectileScript

#

So i put the player on the field

bitter flame
#

try and find out

rancid anvil
#

Yeah but i cant getcomponent of a Transform

bitter flame
#

never did an FPS or any game

#

but may it should work

solid crow
#

Hi all, I've realized that moving something according to a trig function with Time.time isn't a good idea in Photon PUN because the syncing and movement becomes incredibly off really quickly- is there an accepted way to make something that like work consistently?

#

My text editor is telling me PhotonNetwork.time doesn't exist

spring crane
#

Did you try PhotonNetwork.time or Time?

#

Autocompletion should handle this for you

solid crow
#

im a little sad that it was a capital letter stopping me but thank you

spring crane
#

Your text editor should handle this stuff for you. Make sure your editor is selected as the external editor in Unity

hallow fractal
#

hello

#

wow this section was 8 hours unactive

#

just asking a question, is this the right place to ask questions about animation sync in unity?

stray scroll
#

@hallow fractal If regarding syncing animations of networked games yes

stiff ridge
#

@solid crow: I'd recommend having a look at Simple Network Sync 2. It's an addon for PUN 2, which gives you a tick based sync system, sync vars and more. It should give you better results than TransformView and you don't have to figure out how to time things.

#

Make sure to do the tutorial. Feel free to ask questions about it on the discord server for Photon (see readme).

rancid anvil
#

how can i reset a sync var on game join (start)

#

?

jade glacier
#

Should always indicate which lib you are asking about, since this channel covers so many @rancid anvil

rancid anvil
#

Mirror

jade glacier
#

For UNet/Mirror/MLAPI only the server sets syncvars, and it will be started in whatever state you initialize it to normally

echo maple
#

Hey any tutorials out there to implement a lan multiplayer where players host their own server and join host ip?

jade glacier
#

Every networking library from basic transports to full stacks do that - so you likely want to narrow down the kind of game - so you can narrow down which networking library makes the most sense for what you are doing. @echo maple

#

You basically just asked for the equivalent of "how do find a tutorial on how to build a vehicle"

#

I would if you are just totally new, do some tutorials for the upper layer libs like Bolt, Mirror, PUN2

#

or NetCode if you are determined to go ECS

#

Otherwise just connecting... any transport layer can do that

#

For lan though, PUN2 is off the table, as well as Bolt

echo maple
#

Alright thanks, i'm trying to allow clients to create lobbies of 4 but i want the client to create their own servers, and one joins the host ip...

jade glacier
#

That is not lan then

echo maple
#

I already have Pun2

jade glacier
#

You want actual lan? like only players who are inside of the firewall?

#

Or you mean you want players to be able to host internet games?

echo maple
#

no i just want players being able to connect to each other

#

yeah

jade glacier
#

Then leave lan out of that description or you will confuse people

echo maple
#

whoops

jade glacier
#

LAN means people all on the same local area

echo maple
#

yeah

#

i'

jade glacier
#

Bolt, Mirror or PUN2 would be the tutorials I would run first

#

Just to see the various architectures

high night
#

what mirror comes by default is an ip field
which works same as in minecraft
you can host lan
you can host with hamachi ip
you can do port forwarding and host worldwide
@echo maple

jade glacier
#

I think he is more looking for what will become nat punch

#

its not going to be easy what he is after

echo maple
#

im thinking something like this

jade glacier
#

That is actual lan

echo maple
#

but than they would have to port forward themselves

#

for other people to join

#

which would suck...

jade glacier
#

Most people will not do that nor understand what that even means

echo maple
#

yeah exactly

#

my game is already built for multiplayer

jade glacier
#

so for a real game, you have to either host yourself, use a relay, or build in nat punch

high night
#

steamworks is basicly a relay but with infinite CCU limit afaik

#

Mirror has steamworks transport

#

if your game is going to be on steam, you might wanna check it out

echo maple
#

yeah it is on steam ^^

#

ill forsure check that out

#

just having troubles

#

thanks for the help tho

#

ill look into that

jade glacier
#

Some of the libs I think have steam transports in them. I would check the Mirror and MLAPI channels about that.

echo maple
#

alright thanks

frozen canopy
#

Hello there, how could i host a Photon multiplayer in a server? so i dont pay per onliline player quantity

stray scroll
#

@echo maple May I be blunt and ask if you have license to use that music piece by Whitesand?

echo maple
#

?

#

Link it please

#

@stray scroll

stray scroll
#

Might be me being too hasty, but you linked your steam page before didn't you? @echo maple

echo maple
#

yah

#

Ok good was just making sure

#

thanks tho

stray scroll
#

And the answer to my question?

#

@echo maple

echo maple
#

Can i get the link to the music piece please

stray scroll
gleaming prawn
#

@frozen canopy you always have to pay to use our software.

#

It's way cheaper when you host the server yourself

#

But you still have to pay something.

frozen canopy
#

yes but lot cheaper

#

@gleaming prawn

#

i could pay myself a 140โ‚ฌ per month OVH Game Dedicated

#

that is able to handle thousands

#

of players

#

thousands of players in Photon costs like 500-600โ‚ฌ

#

per month..

#

LOL

#

how many GB usage of traffic?

gleaming prawn
#

Why was my message deleted?

echo maple
frozen canopy
#

How many GB of traffic usage

gleaming prawn
#

@frozen canopy when you self host we do not acare about GB traffic

#

Traffic, etc, only means something when hosting in our own machines

frozen canopy
#

You are the leader of Photon?

#

that you talk in "our", "we"

gleaming prawn
#

I'm a core devloper of Photon quantum

#

And I'm well versed in our business model (we = company)

frozen canopy
#

and how can i self-host?

#

i mean

#

look

#

in PhotonSettings

gleaming prawn
#

Anywhere you want, AWS, whatever

frozen canopy
#

it lets me pick SelfHost

#

and let me introduce an IP and port

gleaming prawn
#

Yes, first you dowload the photon SERVER binaries

#

Host it somewhere of your choice

frozen canopy
#

and i dont need t otouch anything in code?

gleaming prawn
#

You are talking about the client SDK only

frozen canopy
#

just in PhotonSettings?

#

the code is the same?

gleaming prawn
#

Well, you need to read the docs to setup the server, signup for the license,e tc

#

If you are talking about PUN, code is the same

#

Yes

#

No changes whatsoever, just setup a photon server, add a license file to it, from the client games, set to self host, point to the server you set(ed)

frozen canopy
#

okay so i just need to setup the server and change this to the server ip and port right?

gleaming prawn
#

yes

frozen canopy
#

and the code to create rooms and everything is exactly the same

gleaming prawn
#

yes

frozen canopy
#

can a photon server run in Linux?

gleaming prawn
#

we run the very same photon server software in our clouds...

#

No, Photon Server runs on Windows, using IO completion ports (not regular sockets)

#

We have a Linux/Mac version under tests

#

But it's a new version, not available to public

#

And yes, you can host some thousands of players in a single machine

frozen canopy
#

Amazing

gleaming prawn
#

Pay attention to bandwidth fees from the host providers...

frozen canopy
#

ovh ulimited bandwidth

#

and cpu usage

#

in his dedis

gleaming prawn
#

There's a reason why even big publishers host with us (instead of just picking the server)

frozen canopy
#

a single 80โ‚ฌ per month dedicated could handle more than 1000 players i guess

gleaming prawn
#

Check if performance really works..:)

#

1000 is LOW...:)

frozen canopy
#

lol xD

#

then why the plans costs that much

#

the generic plans

gleaming prawn
#

Photon server handles a "bit" more

frozen canopy
#

hosted by photon

gleaming prawn
#

then why the plans costs that much
Bandwidth

frozen canopy
#

oh can i just purchase a Photon Server? and put that there with unlimited bandwith?

gleaming prawn
#

We actually host on several baremetal providers, etc

#

you can

frozen canopy
#

oh okay when im purchasing a server

gleaming prawn
#

just download photon server

frozen canopy
#

im hosting in Photon

#

networks

gleaming prawn
#

Free to a limited CCU number even

frozen canopy
#

yep

#

what do i need to do with the licence?

gleaming prawn
#

No, you are using the 20 CCU PUn free, in OUR servers

#

Download the SERVER binary, host it... I think it starts with 100 CCU free,..

frozen canopy
#

Oh okay so im not purchasing a Server, im purchasing the licence to run photon in a server with specific ccu

#

right?

#

here i though i was purchasing like a vps

#

or something

#

to use it for photon

gleaming prawn
#

You need to specificy what you mean by a SERVER... I always refer to server = Photon Server (software)

#

Not hardware

frozen canopy
#

i was refering to a VPS or Dedicated server

gleaming prawn
#

You download the photon server (software)

#

Host it anywhere you want (physical server baremetal, VM, at home, whatever)

frozen canopy
#

At home too? xD

gleaming prawn
#

Yes... Just run it

#

License is limited

#

But when you need to scale, prices for the large licenses is a lot lower, like I said

frozen canopy
#

The free one isnt

gleaming prawn
#

It's all in the website

frozen canopy
#

ah yea, in ccu

gleaming prawn
#

yes

frozen canopy
#

going to watch a tutorial to setup the server

gleaming prawn
#

It should be easy

frozen canopy
#

Im not good with networking

#

had to pay a guy to install my photon

#

50โ‚ฌ

#

xD

gleaming prawn
#

hmm

#

You'll pay a lot more money to these guys than to us... Keep that in mind..:)

#

lol

frozen canopy
#

xDDD

#

i love photon then

#

ill purchase 100โ‚ฌ month windows server

#

and pay the 175/month

#

licence

#

of photon

#

it isnt

gleaming prawn
#

You can also develop everything yourself for "free"

frozen canopy
#

it isnt overpriced paying 275โ‚ฌ per month if i can handle +2000 players

#

at the same time lul

gleaming prawn
#

Or "free" like Unreal...:=

frozen canopy
#

with +2000 players at the same time ill be winning x5 times 275โ‚ฌ

#

lmao

gleaming prawn
#

That is out of my scope...:)

frozen canopy
#

my game has paid skins, ads to unlock some skins

#

so lot of revenue i hpoe

#

hope

#

and the webgl

#

has ads

#

3 banner ads

#

on the sides

gleaming prawn
#

One thing thoug

#

Are you sure you understood CCU?

frozen canopy
#

yes

#

CCU = Concurrent players playing at the same time

gleaming prawn
#

To get 1K CCU you need about half a million players

frozen canopy
#

what

gleaming prawn
#

Yes

frozen canopy
#

no

gleaming prawn
#

Because your players never play at the same time

frozen canopy
#

to get 1k CCU i need 1k players playing at the same time

gleaming prawn
#

Yes... But in REALITY

#

What WE know is:
MAU = 20x DAU = 20x CCU

#

so 1K CCU -> 20.000 DAU (daily active) -> 400.000 MAU (monthly active) -> 0.5-1M downloads

#

So before you think about pricing, you should know that you need a VERY successful game to even SCRATCH our pricing...

frozen canopy
#

i know, but my game is a game that the players play at the same time yes or yes

gleaming prawn
#

You normally would be getting revenue by 7 digits

frozen canopy
#

and i could easily have 100 players playing at the same time

#

in the same room

#

at the same moment

gleaming prawn
#

Well... To have 100 players in the same room you'll have a lot more things to solve first..:)

frozen canopy
#

what things??

gleaming prawn
#

First you need 100 players to WANT to play your game

#

At the same time

frozen canopy
#

Easy

gleaming prawn
#

Ok.

frozen canopy
#

whats the second issue

gleaming prawn
#

Don't tell your formula to everyone

#

People might copy you...

frozen canopy
#

but not all of them have the same contact as me

#

contacts*

#

potential contacts

#

to assure a good campaign

#

already have an APP with 150.000 downloads and 1k downloads every day

gleaming prawn
#

Have you ever published a multiplayer game?

frozen canopy
#

nop, just APPs

gleaming prawn
#

Oh, ok

#

Was asking

#

But no games

frozen canopy
#

never

gleaming prawn
#

ok

#

I suggest you start with a single player game then

#

You have no idea what you are getting into...:)

frozen canopy
#

why xD

#

multiplayer brings lot of problems?

#

already tested it multiplayer mode with 5 other people and works like a charm

gleaming prawn
#

creating games is difficults
creating successful games is 1000x more difficult

frozen canopy
#

why?

gleaming prawn
#

creating successful multiplyer is 10x more difficult than a successful SP

#

Well, it is what it is

frozen canopy
#

you just need to implement things that make the user return to the game

#

every day

#

gifts

#

etc..

gleaming prawn
#

It's what the industry experience shows

#

When you say "just", is "just" shows you have no idea...:)

#

Sorry

#

Have to go back to work

frozen canopy
#

okays

#

thanks for the help

#

โค๏ธ

frozen canopy
#

Hello, how can i Instantiate a Prefab in a specific room?

#

oh okay just got it thanks

#

anyway

frozen canopy
#

what happens if a player has high latency internet?=

#

with photon

#

othe rplayers see him lagged?

#

or he sees other snakes lagging?

frozen canopy
#

k

#

Hello there, the distance between my players in each screen doesn't match just by a little cm, how can i fix that?

jovial rapids
#

move them a little cm

frozen canopy
#

how

#
// Update is called once per frame
    void FixedUpdate()
    {
        if(!view.isMine)
            rootBody.transform.position = Vector3.Lerp(rootBody.transform.position, newPos, Time.fixedDeltaTime * smoothing);
    }

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        //sending and receiving the position
        if(stream.isWriting)
        {
            stream.SendNext(rootBody.transform.position);
        }
        if(stream.isReading)
        {
            newPos = (Vector3)stream.ReceiveNext();
        }
    }```
#

thats my code actually @jovial rapids

frozen canopy
#

whats bad?

jade glacier
#

That Lerp though

harsh dew
#

Lerping into eternity

amber trench
#

lol

empty yew
#

Just trying to change the player object's name

#

well actually, the debug isn't going through

#

does it not like passing gameobjects/

#

It does not like passing gameobjects

#

i solved it, passed the photonview id, although not the one i wanted

frozen canopy
#

What happens if in Unity Multiplayer game, the first person that joined the game disconnects? Tag me on answer please

spring crane
#

If host disconnects, everyone gets kicked. If the first client disconnects, only that client is removed and nobody else is affected.

empty yew
#

not sure why it's giving me issues about the ids

#

How do I properly DontDestroyOnLoad with PUN2?

#

I want to keep the data from the gameobject while changing scenes

empty yew
#

Is a Singleton the solution?

wicked marlin
#

@empty yew Typically, I set AutosyncScene to true on all clients, and then on the master client only, use the PhotonNetwork.LoadLevel to change scenes. That way everyone stays connected and the PhotonViews are all preserved. Does that apply to your problem?

empty yew
#

My computer is off for the night, but I will try this tomorrow. I just loaded the scene normally with scene manager

#

If I can't get your advice to work, I may just forgo changing scenes

wicked marlin
#

Yea, that will destroy anything that isn't DontDestroyOnLoad like normal, I think it's easier to use the PhotonNetwork.LoadLevel instead, that way you don't have to worry about it.

empty yew
#

I'll try that tomorrow. Thanks!

wicked marlin
#

You're welcome!

empty yew
#

I did have dontdestroyonload though