#archived-networking
1 messages · Page 64 of 1
Then it might just be extendable by replacing the lookup code in that Instnatiate method with a check against addressables as well.
I'll mention extending the core instantiate to Tobi to include addressables in the future.
Thanks a lot!
Best bet is to run the tutorials and ask your questions here. Asking if you can ask a question rarely gets replies.
@jade glacier I guess there is a bug in PUN2. A friend of me has map triggers with colliders. These triggers are disabled when ! IsMine (disabled on the Player), but even if the script is disabled, the collision trigger method gets called. We now have used inMine on the trigger instead of in the script on the player, but that's just bad. If you could forward it, it would be awesome!
so... quick question for photon pun. how would i add a paramater to a room eg: a float. and have weather or now a user joins that room based on that float? thx
Does disabling a script stop ontrigger callbacks on unity? Not sure that is a pun related behavior.
Well, in Player.cs is OnTriggerEnter(). When I disable the Player.cs script, the script won't work and OnTriggerEnter() never will get called. With PUN2 OnTriggerEnter() gets called. No matter if the Script is disabled.
That doesn't really make sense though. PUN2 can only be used to control if the script is enabled.... it has no control over if PhysX will generate a trigger event. That isn't part of networking in any way. @woven loom
I would check and make sure the things you expect to be enabled and active are right
I've build a MineMonobehaviour. In Awake() i'm checking !isMine. If so, I disable the script (enabled = false;). Nothing should get called and it's not getting called when I'm not using Photon. I'll recheck what I'm saying, but that's the current state.
awake is also likely way too soon to check ismine
you should really be doing that in a OnJoinedRoom callback
Well, the scripts attached to the prefabs are getting disabled.
This is working like expected.
I'm probably missing your question then
but it sounds like you are saying scripts are getting OnTrigger callbacks when disabled,
PUN does not interact with the PhysX system in any way
I totally get you @jade glacier .
Keep in mind that disabling a script and disabling a gameobject are going to be very different - may or may not be related
But OnTriggerEnter() is in the script which gets disabled. It still get's called.
as it should
script.enabled doesn't affect trigger events
stick your ismine in that ontrigger if you want to ignore triggers when disabled
if the test is not related to networking, yeah
Or disable the gameojbect itself or the collider
We should've researched enabled first. Thanks a lot.
leaving colliders in the physics system may or may not be desirable if you intend to ignore them.
If you want to trigger to still work for other components, then check your script like that... otherwise disable the collider/gameobject
I'll just add
public virtual void OnTriggerEnter(Collider other)
{
if (!enabled) return;
}```
... to `MineMonobehaviour`.
We thought enabled will be enough.
that will work, but if your intent is to make the object not in the physics system for all components, then disable the collider. Or you will have to stick that everywhere
Just change your code to disable the collider rather than the script
Or typically you just put all of that stuff on a child gameoject that you setActive based on if that object is alive and visible
when its dead, you disable that child, nuking all things on it... such as the player model, sound generators, cameras, scripts, colliders etc
It's a trigger on the map which causes the camera to rotate with CineMachine (as far as I can remember).
If it makes sense to do it with an enabled check, do that for sure. I have no idea what you are up to.
Just saying that test is a very spot fix and in most cases not what you want.
np, gl
Working with PUN. What is this layer?
the root layer of the animator
so animator has multiple layers in Unity?
I did not know that. Thanks
so it must be Unity concept right? this animator layer thing
Not sure about other applications, but yeah, you can have multiple layers and they can have masks of what they move.
steam remote is video streaming... you don't need any netcode for that (but as every streaming solution, good luck)
New netcode is based around Server-Client architecture. You can still run server in one of clients if you want. But NetCode is still preview and far from finished. So if this is your first entry to multiplayer games, try something simple like pong or tic-tac-toe with sockets. Then read up on some architecture like https://gafferongames.com/https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking etc.. then you should check out alternatives like Photon, Mirror.
local network, yes
that IS streaming video for your friend
@wispy salmon
basically game runs in local multiplayer mode but shares one player input to your internet buddy and streams the video from the computer that runs the game to that remotely located person
of course there's regular steamworks networking out there
but the remote play feature specifically is just streaming input and video
Does anyone know how Minecraft servers work? Is everything client sided but the server just checks if the player is moving too fast or flying for example?
Does anyone have experience with Colyseus?
I've been looking into how people achieve multiplayer games in Unity and a lot of people recommend using Photon PUN, Playfab, GameSparks, or other BaaS.
Rather than using a BaaS, I'd prefer to use a framework/library that's more code focused. I found Colyseus JS, which is along the lines of what I'm looking for but I want to know if there's any alternatives. I've also played around with setting up a simple http/websocket server as the back end, but if there are frameworks or libraries catered towards game networking that could save me a lot of time.
I suppose the first questions are
- have you made anything networked before?
and - What are you ultimately trying to make?
@tepid steppe Can't speak to Colyseus though
Game wise, I have very little experience (I used to play around with VB6 and a game engine called Mirage)
I work a lot with web sockets and restful api's in my current job. (Both on the backend and consuming)
I'm ultimately trying to make a turn based game which is mostly single player but actions must be validated on the server, and has some interactive elements where players can play against each other.
Cool, that definitely gives you way more networking options. For that type of game you mostly have to work out the simulation, since you will be doing some form of lockstep most likely. And work out how you want to host it. That kind of game is very cloud friendly since it doesn't actually require any Unity-based server logic. For turn-based you really can focus first on the actual game simulation and networking later... but you do have to keep it all deterministic to do that.
Not really answering your question, but I would say make a basic turn based demo, like tick tack to or something and try to integrate with the various services, and see if you even need those services.
For game networking I STRONGLY recommend against going right after making your dream project, because networking involves like a year of constant failure and refactoring. Way less soul-crushing if you learn all the of the caveats making some crappy little nothing game.
That makes sense. I was planning on making a bunch of crappy prototypes of the core game play for the game before actually starting on the project in order to figure out if the gameplay is fun and to get a stronger grasp on networking with games.
That's a good idea, I'll try making a simple game with multiple services to see if I need them or not. I've already played with Colyseus which I found pretty pleasant to use.
In your opinion, what are some of the caveats people often run into when dealing with networking in an online game?
Almost always its starting with messaging, rather than simulation.
If your simulation engine is determinstic and tick based, then networking just becomes a function of storing user inputs and resulting states in buffers.... and then using messaging to share those.
If you start with messaging, you will tend to start throwing messages, RPCs, and Syncvars around and end up with a tangled mess of race conditions.
Messaging <--> Input/State Buffers <--> Simulation
Messaging and simulation should never touch.
And if you can make it deterministic, it looks more like Messaging <--> Input Buffers <--> Simulation <--> State History Buffer
@tepid steppe
Sorry, I had to google some of the terms you mentioned as I'm pretty new to game development itself. This is definitely a lot to think about and I appreciate your info as it gives me a lot more direction for what I need to focus on. I'm going to take your advice and try making some smaller games to get a hold of networking in games haha
gafferongames.com has a lot of good articles for new net devs as well. Worth poking around his site.
Thanks for sharing, I'll take a look through their site
Does anybody know the best way to stream video on a WebGL build?
new DOTS Netcode package out with Unity Physics support, pasted changelog (without upgrade guide) on #archived-dots: https://discordapp.com/channels/489222168727519232/497874303463850004/681613105532370955
finally
Hi, I'm relatively new in unity, is the new networking system working or should I go with UNET? help please
neither
Any first attempts at networking will be pretty much garbage anyway. Just play with tutorials for Netcode, PUN2, Mirror, Bolt and whatever else you think is worth playing with. Don't try to make a real game for a couple months, it will burn you on in an endless cycle of refactoring and failed attempts.
UNet is dead (if you like the API, check Mirror, the open source version, still in proper development)
and DOTS netcode is very very experimental
For learning, netcode is ok then, correct
But UNet is dead, go for Mirror
Once you get through some tutorials for various libraries, you will acquire the vocabulary to even ask the right questions, and be aware of the pitfalls involved in the various libraries.
Then you will be ready to understand Erick when he starts talking about the joys of determinism 🙂
Any first attempts at networking will be pretty much garbage anyway. Just play with tutorials for Netcode, PUN2, Mirror, Bolt and whatever else you think is worth playing with. Don't try to make a real game for a couple months, it will burn you on in an endless cycle of refactoring and failed attempts.
@jade glacier Jajaja I don't have so much time
You might not want to go down the networking path if you don't have time to burn, or someone funding your efforts.
You might not want to go down the networking path if you don't have time to burn, or someone funding your efforts.
@jade glacier Right now I'm developing a simple game in terms of networking (I think so), also I'm working like ten hours a day
It's a 1vs1 trivia
turn based stuff is super easy, you can use cloud services and such for that.
And there is any benefit on learning something like mirror in my case?
I would tend to say now, since its primarily a messaging layer. It won't be teaching you networking, it will just be teaching you how to user their message wrappers of RPCS and Syncvars.
The main advantage of a mid level API, like Mirror or MLAPI, is that they do automate the handling of connecting and creating networked objects with IDs
But if you don't actually need a Unity-based server exe, then its going to be for nothing.
There would be more benefit in learning how to make your turn based thing play well with like AWS.
@jade glacier Thanks for your time, I'm going to check a little more of these mid level API, maybe I could add some cool stuff
Just be aware that making a game with those WILL require a machine to host a Unity exe.
Cloud based like AWS, Photon Server or any other number of libraries are paths to not having to support a host machine.
@grand robin
Ok thanks
that would be overkill and expensive
for a turn based game just try to host the game logic with somthing else
You could literally wire up your test game using Google Sheets as your database if you want to get weird. 🙂
Sounds like you are speaking from experience lol
Nope, never gone there - but would be fun to try.
I did turn based games for Facebook running game logic on rest services build with Google app engine
Works and scales well, pricing was excellent
Did this 2010/2012
I would recommend whatever you do, abstract all of your code into layers so that whatever database you end up with on the cloud side... its not hard coded into your game logic.
I think its just you and I talking now @gleaming prawn LOL
In a train, commuting back home
For the various cloud options, do they offer a pretty wide range of languages you can code your logic into on the cloud side?
They used to offer a few, python, java, phb, but this was 10 years ago
I'm guessing the APIs are pretty insane now
Hey guys, if I'm using LiteNetLib or another library to do custom UDP networking, is it common to put network logic in the update loop or fixed update loop?
Network logic isn't a thing really
That you are using that term makes me want to say no 🙂
Simulation logic goes in Fixed, or a fixed timing of your own. That simulation consumes inputs every tick, and produces a new state from applying those inputs to the previous state.
Networking is used to sync those buffers as needed between connections.
Messing should NOT touch your game or simulation logic.
The ideal place for sending messages is after your simulation has run. Or before in the case of sending inputs only, though functionally that will happen on the same tick either way.
yeah I'm sending networking packets in fixed update
I guess specifically i was wondering is there's any performance benefits with consuming server state updates and applying them in Update() but my guess is that it's all dependent on each game's requirements
when you send the packets doesn't matter that much. What you are sending is far more important.
Update will make your sends frame tied in a likely not desired way
There is no correct answer though if you are not running a strict simulation cycle.
my game client has a lot of physics corrections that end up being very CPU intensive on a network state update. I'm trying to do whatever I can to save cpu cycles
So simulation = adhoc... = whatever, its all a mess so just do whatever whenever.
picking when in the update cycle to send won't save you anything
i have a few users who are having performance problems only during networked play so that is telling me it's from that
serializing and writing a packet is going to cost the same at the start or end of the update cycle.
my physics are 120hz, so Simulating Physics at 120hz and doing it 20 times in a single FixedUpdate is what I'm trying to imporve
just seeing if networking could be coming into play here too
You want a 120hz net rate as well?
120hz for a networked game is going to start testing some limits of a lot of things
right now net rate is 120hz but i'm gonna test networking at 60hz tonight
Why the high rate? so that you have a high net rate, or just because you need it for your physics model to work?
for physics or networking?
physics is at 120hz for accuracy (I get object tunneling at 60hz)
ok, so you don't need that high a net tick probably... so send every X ticks
networking is at 120hz just because i'm sending a update from the server on each FixedUpdate currently
Are you doing server auth with clients sending only inputs?
or are clients doing state transfer to the server?
yes
only inputs
auth server
just not very hopefuly the network tick rate decrease will solve this problem
Then I would recommend sending inputs at full speed, and have the server send every 2nd or 3rd state out
since the client will still be doing 20 ticks of physics at 120hz in a single FixedUpdate
just doiung it every other tick instead of every tick
The lower the net rate the higher the induced latency, but that is the tradeoff for not crushing your server
wait what?
The performance problems are on the client side from the physics state corrections
Why is a client doing 20 ticks in a fixed?
from state corrections
rewinding + resimulating physics
I guess that is part of the insane tick rate yeah
network being a lower tick rate won't change that
it will just mean a state correction happens less frequently
Cutting your tick rate in half would obviously dramatically cut that CPU usage down
Yeah for sure
You probably want to revisit what your resim consists of?
how much stuff is going into this resim scene?
I tried at 60hz for both physics and networking, but it made networking more rough inherently
7 dynamic rigibodies total
6 players and a ball
and all 7 objects are a primitive sphere collider
Sounds like you might just be bumping into the limits of using PhysX and you are becoming a candidate for DOTS, or a different physics model
Yeah switching to DOTS isn't really an option imo
that would be an entire game rewrite
You are going to have to give something up it sounds like. If your physX resims are profiling as the problem, you are kind of stuck.
yeah i profiled and all the cpu time is coming from Physics.Simulate
my velocity solver interations are at 1, my solver iterations are at 4
You have optimized that as much as possible?
removed everything unrelated and set physics layers as minimal as possible
I remember trying Bullet in the past, but it seemed even worse when it came to time spent simulating a single tick of Physics
@jade glacier what do you mean with the physics layers?
simulating 7 bodies shouldn't be that brutal
It's 7 bodies in an arena that has a non-convex mesh collider on it
are not including colliders that have no business being part of the resim, or that won't interact with certain other colliders
Mesh collider might be a big hog
try a test arena with just 7 box colliders
mesh collider means each face is a collider
that's a good idea just for a sanity check
or whatever it reduces that mesh to... but its going to be more than a box collider
yeah, i just definitely need the complex physics of the mesh for the game to pan out
but it's basically like a Rocket League arena shape
mostly flat faces, but beveled/curved corners
dont know what to tell you. You have to give something up
You can fake stuff with a small collection of hand placed primitive colliders
Try the basic map colliders first and see if that even gets you where you need to be.
if so, you will have to give up your mesh colliders and do some hand crafting
yeah let me do that sanity check first
It's super easy for me to switch to Bullet too if i wanna go down that route as I have in the past
Just not sure if the expectation is better or worse performance
I.E. if Bullet is even supposed to be faster
https://play.google.com/store/apps/details?id=com.emotitron.TeapotAvenger&hl=en
I literally hit that wall with my first unity game, and ended up doing a lot of hand placing primitives, or just incorporating primitives into my level design. This as a result plays on crappy phones.
I just know Rocket League runs physics at 120hz with Bullet without a problem
PhysX?
I don't understand the question
what has a massive amount of waste built in?
okay yeah I believe that haha
is bullet physics stateless?
no
rocket league is not using a stateless physics engine?
how can you do clean rollbacks/resims without a stateless physics engine?
what do you mean?
you make a second scene with very thin clones of just what is needed
basically a scratch pad scene
why do you need to even do that?
apply the rewound state, reapply inputs, and copy the results back. That is if you are doing fractional tests and will be culling things from the resim.
If you are doing a complete resim you can do it in the main scene.
okay yeah that's what I'm doing
You would then apply the states from the rewind point to everything (which has to include velocites) and then resim
its not deterministic though I don't think
correct
leaving
I tried to go single scene only
Afterall a single scene should be enough since i can just save/load states and simulate whichever i want, i though
as long as you save/load state for everything
I'm not having any problems in my game with that
and all the invoked OnCollision functions, unapplied forces etc
Granted, I don't need 100% determinism since the scene gets corrected extremely frequently
Physics corrections and resims are working with PhysX well enough for a playable game though
server - host
if(tickTime){
LoadState(lastReliableState);
SimulateUntil(serverTime);
lastReliableState = SaveState();
SendToClients(lastReliableState);
}
SimulateUntil(predictionTime);
This was my problem pretty much
When to go to past with LoadState(), you can't reload past state's physx cache
And bring in a different physx cache from predictionTime
oh i'm not familiar with a use case of server-side rewinds
Every physics networking design I know of only involves needing to resim on the client side
This is a case where server also plays 😄
ohhh okay
as host you know
if the server is playing though, they shouldn't need to ever rewind
if they are the authoritative figure
takes back where it left the server simulation,
simulates a little,
and then uses that info as if it was a client
idk i can't think of a reason so have the server resim
Not saying it's wrong
Just doesn't make any sense to me
server player needs to see future too
why though?
but in future, other player inputs arent recieved yet
server plays the game as well as a player
its host
?
it just still doesn't make any sense haha
hm
i don't see what you are gaining from that other than giving the host "fake" latency
it's not fake latency,
those inputs from other players aren't complete yet
the other clients will be in the future compared to the host, but the host doesn't need to be in the future
right, which is why the clients are ahead of the server in tick correct?
if the host is on tick 100, the other players will/should be on like tick 110-120
so that by the time their inputs reach the server, that tick hasn't been processed yet
host reliable state will be at 100 too,
but host will see tick 120
all clients are seeing tick 120 as well
that's what I'm saying
okay then
the host doesn't need to see tick 120
It doesn't serve a purpose
just show the host tick 100
then the hosting player would have input latency?
why would they? their inputs aren't going across a network, so you would be processing their inputs directly
you register hosts input at frame: 100 or something?
i think you are trying to treat the host's inputs the same as a remote client when you don't need to
when the server/host is processing inputs for itsself, all it needs to do is take the current input in real time
Then you'd have to register the input at server's reliable time the frame=100
Is that what you are doing?
if (player.isRemote) //find input packet matching the tick and process it
if (player.isLocal) // player.inputs = Inputs.GetKeyDown(), etc.
all host input should be 100% realtime
it shouldn't need to be buffered
but host lives in the past compared to clients
and then the host shouldn't be in the future
this isn't normal logic right?
this is something weird but works in practise type of weird?
let me ask you this
if you took your game, and made a dedicated server
so that all players are remote
would your server still be resimulating physics?
do your clients currently resimulate physics at all?
i think you have flawed logic in your server logic then
i was going to send the state immidently as soon as all player inputs for the tick is recieved
haven't done that yet though
maybe I just don't understand your game design
what kind of game is it?
your server should never "wait" for player input
yeah i don't see a reason you would ever resimulate physics on the server for that
this is the game, i have mp version too but havent uploaded yet
the clients should be the only ones resimulating
got ya, I played Mordhau
But yeah, resimulating physics on the server sounds like the incorrect approach for this style of game
@glacial totem Wait if i had the server as a dedicated server, i wouldn't run any resims
only on clients i mean
okay that makes a lot more sense
then if you wouldn't resim on a dedicated server, you shouldn't resim on a player host server either
server would send state as soon as inputs from all players recieved for the tick
The host's server should work exactly like a dedicated server would
no, player host would have to wait just as long as everyone is waiting
and resim with the state from the past
but the host's local player doesn't do any networking and doesn't live in the future
yeah i think that's flawed
what is the server waiting for?
inputs?
inputs from all players must be recieved per that tick before server sends out a state
or in 20 frames at max and then server sends the state
so what happens if one player lags
its the max latency for a player
inputs are rejected
and player rubberbands and cant move
yeah i think you might have the wrong approach to your problem
server shouldn't be waiting for anything or doing anything complex
it should simply get all the inputs it has for the tick it's on, process them, increment the tick number, and repeat
if a player's input isn't there yet, or it's not reaching the server on time, that's a problem you solve on the client side
all clients should be in the future, but based on their own logic
client 1 has 30ms ping, client 2 has 50 ms ping, so client 2 should be more ticks ahead than client 1
exactly!
more time for input to reach server
if the inputs aren't making it in time. what I do is I have the server tell the client it's behind
and the server tells the client it needs to more ahead into the future more
hmm, thats kinda weird to think about though, living in different times
yeah but it makes sense
me and you are on the server, and the goal is that both of are inputs are processed at the same time so it's fair
but if I'm laggy, you shouldn't be punished
that's my fault and my problem, no yours
So if a player is too laggy, does that player see a falling box hit the ground earlier on his screen?
yeah, the laggier the player the more extreme corrections might be
have you ever watched the Rocket League GDC talk?
i did but i may not remember details
They explain the entire system they use, and all I did was watch that video and try to copy what they did
and I'm having a ton of success
I'm not
I only run a single scene
when i get a state update from the server, i rollback my entire main scene, then resim, then continue on as normal
The catch is that you would need to resimulate all objects
so for you that would be every single player and every arrow, etc.
@glacial totem the pwrf numbers you are getting seems very bad
for me that's only 7 objects total: 6 players and a ball
I know we can do 20 tick rollbacks with a simple rocket league like game no problem with our 100% deterministic physics
That's not even a question
I'm saying we can run 20 ticks at once no problem...
I agree that it doesn't seem like something that should be as performance heavy as it currently is
But I'm talking about our own stateless physics engine
is that a proprietary solution I'm assuming?
I expected a non deterministic one to be faster, but physx is not made for rolling back
But what about oncollision invokes,
If a collision is invoked the frame you recieved a new state
And you did the rollback on that state
That collision will leak into the that past state, ruining your 10 - 20 frame determinism
@glacial totem
So the cost must be in the creating the broadphase or even the state copy
Well, yes, proprietary.... But your physics requirements seem low for running into issues with physx
But maybe I'm underestimating how bad it is for rollbacks
@high night it all depends on what those collisios trigger. for me personally, the incorrect collision is discarded and the new one generated from the resim is used
@gleaming prawn that's why I'm also open to using another physics engine
As emotitron always says, I'm just glad I do not even have to think about the problems you are describing...:)
physx isn't even deterministic, so having determinism for my use case would be so much of an improvement
@glacial totem you are able to serialize the collision in states?
@high night i only ever use oncollsionenter
Ours is a complete multiplayer game engine, and yes we built a rocket league for mobile with it already (30 or 60 Hz because mobile, could run at 120 on pc, no problem)
Collision Stay and Collision Exit aren't used in my game
Is this a proper game you want to release, or just a hobby project?
@gleaming prawn 100% intent on releasing at this point. Started as a hobby but I think it has potential.
Even if just a hobby, we're always interested to contact good Devs for potential collabs (not necessarily we need to think of anybody as a customer)
The people testing are playing the game on their own and enjoying it. They aren't being forced to play. So I think that's something
Looks cool, is it just a rocket league clone?
@glacial totem Are you not serializing the collision forces in OnCollisionStay?
I mean, those forces don't affect velocity immidently so if you serialize before next frame, you'll be missing that info
And in the next frame you already have new forces generated and haven't yet applied to velocities
Yeah you will need the velocity and angular velocity in your state sync
There's no right time window to serialize and create a correct state with physx i thought. As soon as the physx uses it's cache to update transforms and rbs, it creates another cache. That cache might even have information from previous states who knows.
Thats why i'm trying to use the new Unity.Physics in dots
I have had moderate success in the past of polling RBs post Physx.Simulate(), but its very much not deterministic. He is mostly going for close enough though since its in a constant state of resim
Hi all i am working on FPS Multiplayer project and i will be using AWS server, can anyone please tell me if amazon have different packages for multiplayer and does the programming C Sharpcode differs based on the packages i will be opting?
Hi, is there a Photon specific discord server or can I ask my photon pun 2 related questions here as well?
So with a bit of precision lose it is possible to pack 2floats into 1 int. My question is is this possible with 3 floats in a small range ? Like x,y,z are in between -10.0 to 10.0 with at least 1
decimal point.
you can store 4 floats in one Int
using Q4.4 (but that is in the -7 -> 7 range only)
and very very low precision
or Q5.3, which would give you the integer range you want
FixedPoint formats
that's what is normally used for cross-platform determinism (RTSs, we use in Quantum)... In our case Q48.16 (Int64)
Interesting!
If you aren't going for determinism and you just want to pack lossy floats for networking you can use my lib
https://github.com/emotitron/TransformCrusher
I think that is what you are basically asking about, options for bitpacking floats?
It handles rotation and scale edge cases, gives the option for an accurate center value, smallest three quat compression and half floats
Yea right. I know your lib, but thanks. I need to learn that kind of stuff so i will go for implement something on my own^^
The math is pretty basic, its what Erick posted a link to. Its just a pain when you want to start dealing with the edge cases, like compressing and recreating euler rotations that will wrap all screwy if you don't build in handling for that.
https://github.com/Vincenz099/NetworkingHelpers
I think his bitbuffer has all the float stuff in it and you can just look at it, or use it.
Thanks, gonna look at it^^
His libs are pretty heavily tested for speed, we benchmarked his stuff and mine pretty heavily.
Thanks @jade glacier was unaware of these libs
He does networking on a massive civil war simulation, and it sends one giant single state to all players, so his entire system lives and dies by his bitpacking speed
I don't know though if he has added unsafe read/write and a means of locking the buffer for that. That was the one spot my lib was much faster.
@gleaming prawn Don't think you will have much use for either at this point LOL. You kind of have something way different and better 🙂
Is there any way of knowing in Photon when the value i streamed has written to the other client so I could reset it?
Probably not in the way you are hoping
Since there is no server, trying to check acks against all clients by each owner would become a tangled mess.
You CAN send your message as reliable though
and it will stop all traffic until that message gets through.
It will make a mess of any fast streams you might be trying to achieve, but it will ensure delivery to all.
Oh, does this apply if i have two players as well?
Any number of players, it tells the relay that that message needs to get through at all costs
The relay handles it and will do the RUDP work needed to ensure all targeted clients get it
But it can hold up other traffic, so I try to avoid that and instead opt for keyframes for eventual consistency.
But you can easily give it a shot, just flag your RaiseEvent or RPC as reliable or reliable ordered.
depending on your needs.
Got it, will try sending a message to see if it works
if you send it as reliable unordered I don't think you will mess with other traffic getting through
so you can make your fast unreliable stream, and then send stuff that doesn't need to happen on tick as reliable... like say a score change or some other thing that won't mess with your simulation.
My needs are simple, I just have an int check to enable an attack animation prefab. So when player 1 presses a button, I increase the number of his int, I check if the number of the other player's int is equal to 1 or 2 and spawn an animation accordingly. This messes up since I cannot reset the int and the prefabs keep spawning till I change the int on the initial server
you are starting to get into simulation there, so you are going to be going down a messy path trying to turn your simulation stuff into adhoc events like that
It will all work when you are starting and you don't have a lot of race conditions, but as your game gets complex and order of execution becomes critical that adhoc timing will become a nightmare.
So forewarning.
Yes, it's getting cluttered as it is, will try messages and let you know
No need, I know how its going to turn out 🙂
Its going to work fine. The issue is as your game logic starts to get complicated the uncertainty of events arriving and processing in correct orders is going to force you to start over and go tick based.
Everyone though has to try the short and easy route first though, to find out why the harder way matters.
Yes, thanks so much for your help 😃
XO i got a weird idea, since i know the exact map size. And i already can pack 3 floats (0.00-1.00) into 1 float. I can use it as a percentage. ```cs
public static float Pack(Vector3 v3, Vector3 min, Vector3 max)
{
var x = (v3.x - min.x) / (max.x - min.x);
var y = (v3.y - min.y) / (max.y - min.y);
var z = (v3.z - min.z) / (max.z - min.z);
var retVal = ((int) (x * 65535.0f + 0.5f));
retVal |= ((int) (y * 255.0f + 0.5f)) << 16;
retVal |= ((int) (z * 253.0f + 1.5f)) << 24;
return retVal;
}
public static Vector3 Unpack(float f, Vector3 min, Vector3 max)
{
var i = (int) (f);
var x = ((i) & 0xFFFF) / 65535.0f;
var y = ((i >> 16) & 0xFF) / 255.0f;
var z = (((i >> 24) & 0xFF) - 1.0f) / 253.0f;
x = min.x + (max.x - min.x) * x;
y = min.y + (max.y - min.y) * y;
z = min.z + (max.z - min.z) * z;
return new Vector3(x, y, z);
}```
I 100% encourage making hot messes when learning networking. As long as you have time and its fun.
@weak lava That's called normalized, but not really needed, its just an extra math step for no gain.
If you know the map size, you are already in a winning place for converting your floats into uints and bitpacking those.
All you end up doing is creating an encorder and decoder value to multiply against, and then you add the lower range value. That won't make sense as text, but its very basic.
I'm not reading all of that, but be aware that if you are picking up items, they are going to likely have a different owner.
So you will have to work out the exchange of ownership, or include reparenting info in the transaction.
If would include it in the RPC, so it all happens on the same operation without producing race conditions yeah.
Shared objects are notoriously tricky, especially in a relay environment
public override void OnConnectedToMaster(){
Debug.Log ("connected");
}
what???
Is that PUN2 or PUN ?
i fixed it
Hi all, I am working on Unity(2019.3.2f) FPS Multiplayer project and I am planning to opt for AWS(Amazon Web Server) can anyone please tell me if amazon hasI different package for multiplayer and does the programming code differ based on the packages i will be opting?
Hi. We are using PUN2 any idea how to deal with piracy ? Lets say our steam game gets cracked how do I stop the pirates from playing. The game is only mutiplayer.
@wanton scroll piracy is something you need to deal with the tools from steam (distributor) and your own. Photon has no relation to what you can do there....
Photon has external authentication options that can force your players to go through. For example steam Auth or Facebook, etc
That helps you to make sure players are at least logged users....
If you enforce via steam, maybe that helps...
But that is not strictly a photon tool, they just accept external authentication before a player can get into matchmaking, etc
I was thinking that exact thing. I just dont know if they crack our game if it will not show up in steam so to speak.
This would not prevent a player form downloading from other sources, but at least it might prevent these from playing, if your Auth identifies players who own the game copy
They will crack, but these authentications happen on the server...
Our game is just multi player so that shouls be reasonable enough protection I think
So they would not be able to login to the official servers unless they own a copy (assuming your steam Auth can enforce that)
Glaubst Just pure piracy it might help, yes
Authentication and rewarding player with progress prizes is one of the major ways the industry is dodging piracy
Online only, etc... Free to play...
Challenges are others... Not piracy (at least for online only)
Ah I can set check ownership in the pun dashboard and just send the steam session ticket
That should teach those pesky pirates🤣 😀
There is documentation on how to setup custom auth
Not sure if steam is turnkey, it might be.
If in doubt, send an email to developer@photonengine.com
Than you yet again for the great info.
Global cross platform multiplayer game backend as a service (SaaS, Cloud) for synchronous and asynchronous games and applications. SDKs are available for android, iOS, .NET., Mac OS, Unity 3D, Windows, Unreal Engine, HTML5 and others.
It's pretty turnkey. Using the SDK hooks Steam, and if you're logged in, you can get a session ticket, which serves as auth
Yeah I found this too. I was rather asking if this is enough to stop pirates from playing our multiplayer game
Guys, i have never heard about how to make an multiplayer game or anything, but how does Photon actually work
Like how do you connect to a server
Make a server
@wanton scroll https://partner.steamgames.com/doc/features/auth
@weak plinth there is very decent documentation on the pun website. I've never made a multi game too and using that I was able to make our latest game
tl;dr, yes. The session ticket system is used to verify a user's Steam identity, and can be used to verify ownership of the game, as well as other profile information, like VAC bans
So a hypothetical pirate -- by which I suspect you mean someone who didn't pay for the game but has the client -- can't play without a valid Steam account that owns it, if you use session tickets to auth them
@wanton scroll but how do you make your own server, can you host one online or do you use your pc
You dont
I only want to know that
Pun is the server
Its cloud and has load balancing
There are different ways to develop multiplayer piki
And in my calculations it's cheaper than renting actual virtual servers
Ok
Pun is free up to 20 ccu
Ok
Ccu is concurent user
Your question seems you do not understand exactly how pun works, there is another product from the same company which you might relate better
Photon bolt.
That one uses a pure client server architecture, and you can either have players host servers or yourself dedicated ones
Free for up to 20 sinuktaneous
Then the prices are in their website
@weak plinth just go to the website
There's also Amazon Gamelift, SpatialOS, a few other similar services
There's no free product from companies... Unity offers their for "free", hoping you host.yourbgames with their servers
Unreal takes a decent amount of your revenue if you get successful, etc
Free free, you can get mirror
But then you still have to host servers
So, no free...
Check pun, bolt, mirror
Free
See which one you like the most
Yeah
Im not really looking something professional cuz i cant even develop a professional game
But i will remember that
Try the free versions, you will have fun
Well if you are just starting your game I would recomend you check out the new unity dots networking
There you write your own client server that you can host somewhere free for your friends
I'd use mirror for that
I would recommend against the new DOTS networking, especially for a beginner, and especially right now
Until dots gets anywhere close to stable
Mirror is wildly easier
Dots in general is a complete uncertainty
I went with pun in our project because its stable and easy to implement since we have a very very tight productin schedule
And it offer no option for punching, relay, so you'd be stick to hosting expensive servers
Exactly not at all usable in a production env like my case
Pun is great when you're at the point of having things like production schedules.
But might be fun and educational for him
Yeah, on a second step
Pun saved my life and studio haha
It's a bit hardcore for someone starting
Lets just hope we dont all die from corona before we release
And i hope we all die
The earth
🙂
Im in Netherlands and corona is almost there
Keep off-topic stuff in the #497872469911404564 , please. Including reaction gifs and pictures.
Im out😒
they just updated https://github.com/Unity-Technologies/multiplayer/ which now contains a sample showing lag compensation based on Unity Physics
A sample showing a way to implement lag compensation based on Unity Physics. In a game based on the Unity NetCode the client will display an old world state, lag compensation allows the server to take this into account when performing raycasts so the player can aim at what is actually displayed on the client.
@quasi tapir I'm not sure what you are doing with that reliable message, but something to test for is if late joiners to the game see the right current state for whatever it is you are changing.
@weak plinth not reading all of that, but are you changing owership of that object to the player that grabbed it?
I don't see the ownership change at a glance of that code
I'm a bit too buried in work to dig through your code or watch the video closely, but might be good to clearly articulate the behaviour. Where its working, where it is not working, and in what way it is not working.
"Its not working" requires a bit more sleuthing than I can dedicate while working.
What is breaking. It works on the owner/master correctly?
Does that replicate correctly?
"works" is the word I am trying to avoid
there we go
the transform state is not replicating to non-owners
So two problems?
when the master grabs it, it looks right on the master, but does not replicate to other clients?
You are syncing the transform with the vanilla TransformView?
Before getting too deep into this, you might want to set aside 30 mins and run this tutorial for the new PUN2 stuff - its going to replace a lot of that as standard practice, and it does most of this for you.
https://docs.google.com/document/d/1moPBIt8cNe-h1uG01pvaOZQvrIjZfSBfDmVa793X6AQ/edit?usp=sharing
For the vanilla stuff, you use one or the other of those views. Not both.
Or they are going to be fighting for control on the non-owners
when testing connections between multiple clients, how to simulate it? do I need to have 5 different phones to test 5 different connections or is there a better way?
There are a tutorial for a Photon Multiplayer Online?
@weak plinth The supplied stuff is https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/intro
Photon Unity Networking framework for realtime multiplayer games and applications with no punchthrough issues. Export to all Unity supported platforms, no matter what Unity license you have!
It will introduce you to the concepts of using PUN. Making a game is more up to you 🙂
@weak plinth yeah, you aren't meant to use both of those - just one or the other as far as I know. Otherwise they both will end up fighting to move un-owned objects in their own way.
@jade glacier I just send a messages to trigger a local animation on the other player. I only start the game when both the players are present so there is no issue there with late comers. Although I do have an issue where my timer does not sync properly since I start both timers after both the players join and click the start button
I guess I have to change the variable I am sending to confirm I am ready to the player 1 through a message as well
I can't speak to most of that, some of that stuff you just described sounds like a recipe for race conditions and such.
This is a word game. Like scrabble but the ones who form the most words in a minute wins. So what I do is have two players join the room, the player 1 waits for the 2nd player to join at which point I give him a random set of letters, when the player 1 gets his random set, I send it through to the player 2 so he gets the same random set of letters as well. When they both get it, they click ready, when the 2nd player clicks ready, a local timer for him starts while he sends a confirmation to the player 1 that he is ready and a local timer starts for him
I have minor latency issues with the timer, these aren't identified at the start, but when it ticks down more and more, there is a second or two difference near the end
nm, if its realtime then stick with PUN
pure turn based you would want to consider removing all of your game logic from Unity.
I'm coding as helping people in this chan btw, so any large walls of texts I end up just skimming, so apologies if I totally misread you.
No problem
This is realtime, it is been a really fun experience to getting it to work
Now I'm at the part of optimizing it
what do you mean remove all game logic from unity if it is turn based?
It seems you already aren't trying to run any kind of server/database logic so it doesn't really apply to you.
But for turn-based you would typically have a database/cloud of some kind that acts as the server, and all turns would go through that. But because its not a physics based game, you wouldn't want to have to host a Unity EXE as your server, you would want to reduce your code to something that can be run outside of Unity, or run as a script or plugin on the cloud server.
For Photon Server that would be a plugin, for like AWS that would be some scripting.
MUCH cheaper to host your logic like that than have to spin up Unity instances.
You however are letting the clients run the logic it sounds like, and you are trusting them. Thus removing that need, as you are basically letting the Master Client act as your server.
Yes, you are right, I don't have any database logic as of now
Client runs the logic locally, I'm using Photon for matchmaking and for sending data. I do have tons and tons of animation though, so Unity helps me greatly with this. There is a single player campaign mode as well with multiple levels
If you eventually intend for the logic not to be trusted to clients, you might want to wrap that into its own simulation class.
You mean I let the server take care of all the logic and just display it on the client?
That isn't required, but if you can make your simulation deterministic (you should for turn based) - then the server and the clients run the same simulation from the same user inputs.
Your networking becomes very tiny, as its just sharing those inputs. Typically in a lockstep architecture to make it nice and easy.
Ah, I don't understand it clearly, but you are suggesting I just track the inputs which control certain sets of game logics which is common for both the players in case of a turn based game instead of tracking every variable that is changed
That is how game networking normally works. Beginning devs tend to just do everything as messages being thrown around, but once you realize the hell that creates down the line you will want to move toward creating a simualtion.
The simulation is like how PhysX works... it has a regular tick rate, and before it simulates it collects inputs for the next tick (What you do in FixedUpdate) and then once all of that is collected you apply those inputs to the results (state) of the previous tick.
Networking then just becomes the passing of the contents of those ticks around.
Messaging <-> Input / State Buffers <-> Simulation
Messaging and simulation should never directly touch in code.
Once you have your simulation abstracted, then it doesn't matter where it is, its just there to apply inputs to a previous state, and produce a new state.
Deterministic means that no matter which machine you run that simulation code on, you will get the EXACT same state results.
That allows you to only transmit inputs (cheap to network), and you can trust that everyone will produce the exact same result (State - which is expensive to network in most cases)
You can also sync the states if it makes sense instead.
What matters is that everything is reduced to inputs that go into the sim, and states that come out of the sim.
This makes so much sense, feel like this would be easier if you want to disconnect and reconnect as well to start from the last point
I will try shifting my code like this soon when I get a full working flow of it with messages 😄
This is pretty informative, thanks a lot for taking the time to explain this
Never used nor heard of those. But I also don't use RPCs so I don't know much about their usage with PUN.
How would one use UnityWebRequest to POST binary data to a web service? (or barring that, another alternative)
(The endpoint is not ours and it expects binary data, bu UnityWebRequest only seems to allow string data)
Define "binary data". What Content-Type does the remote API specify?
Either way, can probably do this: https://docs.unity3d.com/ScriptReference/WWWForm.html using the AddBinaryData method
In photon pun, host migration is auto
How can off the host migration?
So that when the master leave, the game ends
Just use the PUN callbacks
there is one for master change I believe
OnMasterClientSwitched
@drifting ridge
@jade glacier thanks, it works
@stable epoch host at home 
im pretty confused with this whole [PunRPC] thing. say i want to send the mesh renderer from a player to the server so everyone sees the player in their full glory.
[PunRpc]
void sendMeshRenderer(MeshRenderer mr){
// what now
}
or is it a whole different thing
Not even sure what sending a MeshRenderer would mean... that's not likely to be a networked hash
Its not going to serialize the entire mesh for you and reproduce that if that is what you are thinking.
Not sure that will help any, what you just typed and your code indicates you want to send an entire serialized object... which isn't going to happen.
ill also send the script responsible for setting the color of the materials
"sends the script" ?
the piece of code
Just make an RPC called "SetColor" and send the vector3 value you want to set or something.
if (PhotonNetwork.IsMasterClient) {
if (PhotonNetwork.CurrentRoom.PlayerCount % 2 == 0) {
GetComponent<MeshRenderer> ().material.color = teamColors [0];
} else {
GetComponent<MeshRenderer> ().material.color = teamColors [1];
}
}
or more ideally, index your colors, and send the color index
so just networking the team index
You can't serialize an entire Object and hope it actually replicates... it won't do that.
i saw a really confusing tutorial
How would you normally make a method that sets the color?
yeah, whatever tutorial fed you this... needs to get thrown in the trash.
GetComponent<MeshRenderer> ().material.color = Color.myColor;
rpc the team value... and have each client set the color based on that index
you can RPC color, its a vector3 or vector4
oh so just
void color(Color clr){
GetComponent<MeshRenderer> ().material.color = clr;
}```?
If that is what you are after, yeah. Just RPC that color value
or if you have a finite number of colors, just rpc the team index
Though that is a whole other networking can of worms... because RPCs are =NOT permanent states
i think i finally understood rpc's now
so late joiners are going to not get that message
oh?
i remember the tutorial dude saying something about new clients
do i set RpcTarget.AllBuffered?
I don't touch any of the RPC stuff, can't really speak to actual best practices for that.
well seems like color is not valid here though i fixed it fairly quickly
thanks again
seems to do the job for now
np
Are you sure the ownership has changed for starters? Like use Debug.LogError() to print things to your development builds visible log and put checks there to make sure things are as they should be.
But exchanging ownership of shared objects is never trivial, you have to be very exact in what the conversation is between the original owner and the one grabbing the object.
There is always a period of confusion between when the player grabs it and when the current owner and others recognize that new players as being the owner.
I am not entirely sure what is going wrong, but a glance at the video looks like there is latency between the player looking around, and the object following in a delayed manner, which indicates that the player doesn't own the object.
Side note on doing that well, you will typically want to must network that object having a parent change, rather than networking its global position every tick.
If you tell it that it is mounted .2 units in front of the player, then you don't need to constantly sync the position and rotation. Every player will just see it .2 units in front of the current owner.
Disable the transform/rb sync if you do that
Not sure if the vanilla syncs allow for "local", but that would also solve the issue if they don't sync by localposition and localrotation already internally
Disabling the component might be respected by PhotonView's serialization... not sure.
Yeah, no idea - I don't mess with RPCs for what you are doing. I literally am working for Exit making a system that handles all of this.
SNS
Would be interested to know where it fell down, because it's ultimate intent IS to work for everybody.
Fair enough, though not super informative 🙂
void FixedUpdate
if (PhotonNetwork.IsMasterClient) {
stuff
} else {
Destroy (deleteForClients);
//deleteForClients is a GameObject which includes a camera
}```
this returns me a really weird result:
when the first client joins - the object is not destroyed and everything is fine.
when the second player joins - the second client seems to destroy the first client's object, and now the first client sees through the second client's camera. also what i typed in `if (PhotonNetwork.IsMasterClient)` seems to also try and work for the second second but the second client seems to snap back to where they were before in the next frame.
i believe the if statement is not the correct one
are you sure the network has started by the time that first Fixed runs?
otherwise all ownership bools are going to be false
what do you mean
Not sure how else to phrase that
that this OnJoinedRoom has run and ownership exists
holy shit i forgot about this part
what was it again
i remember you told me what to do
no wait
that wasnt it
the OnJoinedRoom was called ofc
how can i check if ownership exists
if (PhotonNetwork.IsMasterClient) print("ownership exists");?
@jade glacier im confused again
yeah i understand
i found the error i think
it's gotta be "pv.IsMine" instead of "PhotonNetwork.IsMasterClient"
pv being PhotonView
keep in mind what you are doing there with destroy means that that object should never change owners.
yeah, transferrequest or something like that. Don't recall off the top of my head but its easy to look up
Keep in mind that its all asyncronous in nature, so you need to build in tolerance for things not happening in the order expected.
Oof, transferring ownership always brings problems
yup
I think the default owner is the MasterClient
Hi, all, when I'm run in linux headless unity, I'm got error
Can anyone explain what's mean?
unity html5 c# how i can to do something{} if web page refresh/close
how would i change a networked players position with something like gameObject.transform.position without it like breaking
This is how i'm doing it rn
Are you using a particular library?
hlapi
when player dies i want him to teleport somewhere to get respawning animation and teleport back to respawn point
Are you using networkTransform?
yeh
it like on client that died he dont tp back but on remote player (one that didnt die) it shows him floating in air where he should spawn
and falls down when dead person moves
its like rlly broke
Teleporting is usually pretty jacked up with the vanilla transform syncs in many of the free libraries yeah.
is there a dif way to do it?
If you are trying to handle it yourself, likely will want to set the rb to Lindsay while dead, an disable interpolation for the teleport
im usin charcter controller
Hard to say, not sure what is wrong with your code currently.
and have no clue what interpoltion is
Doors it teleport locally correctly?
it teleports player dead if it is !localplayer
but wat rlly confusions me is it fine tping to area for when dead but when tping back it just fails
the player that died doesnt move after dead animation
but for other players he floatin
To many unknowns to say without all of the code and player objects in front of me, sorry.
thanks for attempting 🙂
first person to actually reply without giving me a link to google.com and telling me to look it up
[Photon Pun 2] Does changing the player properties of client A from the master client informs that the property of client A was updated for all clients in the room?
Also, if a new player joins the room, can the player get the updated property from client A using it's actorNumber?
I know changing a room properties is 'global' and you'd be able to get the updated value but I'm not too sure about player properties.
Hello, I was wondering if anyone ever used enet for networking, and if so you probably ended up using the c++ lib and use a wrapper or? Are there any other ways to use this library? I can not find a good port of enet to C# without any dependencies, so I want to create one that is closely inspired by the c++ code.
I am asking what are your thoughts about this, is it worth it or am I missing a point that makes this unnecessary ? And lastly if anyone would be interested to help if it makes sense to build something like that.
Thank you for reading 🙂
@turbid forge https://github.com/nxrighthere/ENet-CSharp
Try this
I am aware of this, but it is not managed(use c++ dll) and its archived, so maybe no future updates. I think there is nothing wrong with the c++ dll / wrapper, but personally I would love a c# managed way (even if performance is lower) What are your thoughts?
Buffered rpcs in PUN should be used very sparingly. They are not a substitute for states, and will cause problems if you have too many, like later joining players getting disconnected.
Someone pls help me
Im trying to make a multiplayer game
Trying to sync players but they dont appear for all clients
Im using photon
Thats my join script:
{
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
Debug.LogWarning("Connected!");
PhotonNetwork.AutomaticallySyncScene = true;
PhotonNetwork.JoinRandomRoom();
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
Debug.LogWarning("No rooms, creating...");
RoomOptions roomOps = new RoomOptions()
{
IsVisible = true,
IsOpen = true,
MaxPlayers = 20
};
PhotonNetwork.CreateRoom("Fight lol", roomOps);
}
public override void OnCreateRoomFailed(short returnCode, string message)
{
Debug.LogError("Mission failed!");
}
public override void OnJoinedRoom()
{
Debug.LogWarning("Joined room!");
PhotonNetwork.LoadLevel(1);
PhotonNetwork.Instantiate("Bullet", default(Vector3), default(Quaternion), 0, null);
}```
Im 100 sure we are connected cuz the spawning bullet worked
I also added PhotonView component to my character
And Photonview Transform
What did i do wrong?
How are you spawning the players themselves?
The prefab that is the player also needs to be PhotonNetwork.Instantiate 'd
Photon Unity Networking framework for realtime multiplayer games and applications with no punchthrough issues. Export to all Unity supported platforms, no matter what Unity license you have!
np
Btw
One more questions
If i spawn them like that
Will the Photonview Transform work directly?
Yes, it should. I think that's the way it is intended to be used.
Ok
And another one lmao
When i spawn the players
And another player joins after i spawned them
Will he see the objects?
Yes, as along as you are PhotonNetwork.Instantiate the player prefab, and that prefab has a PhotonView (with position and rotation checked) then movements of the gameobject will be updated over the network.
Sorry for that many question, new to photon
No problem. I used it for the first time last year.
I would not instantiate bullets. Those typically are deterministic events, not net objects.
No i wont use that command
I was only testing it
To see in the editor
If the bullet spawned
By the other client
That was only to test
@wicked marlin
Something
Do i have to put the PhotonView component on the childeren too
If they got the if (!photonView.IsMine) return; in their script
cuz
PhotonView can go on the parent only.
Ok
I'd step through that
But why m i getting these errors
I think you just have a prefab that's not set or some object couldn't be found. What do those lines of code look like?
Yeah when i dubble click on the error it shows me the photonView.isMine line
What does line 18 of GunManager.cs have?
Where do you set photonView?
I thought it was set already
Does the object that script is on have a photonView?
Oh, I see. Yes, you probably just need to get the component from the parent.
This should work i guess
Worked!
Now i will try to play multiplayer
MY EYES ARE GONE
Nvm they were on an ignored layer lmao
lol
@wicked marlin Could you help me again
The local rotation and local position for the children do not work
I mean update
For others
Sorry, I stepped away for a few minutes.
Add a photonView to the children that need to be updated. If their position is relative to parent, you may be able to uncheck location and sync just rotation. But try it with both (the default) first.
@wicked marlin I added the component to my gun
Still doesnt work
Ignore the color, didnt fix that yet
Thats how it should look:
Is the gun a child of the player object?
ha
Oh wait
Nvm
Im not
I only disabled the camera component
Not the gameobject
So i should still get the camera rotation
Its not only the camera
The eyes too
The eyes are the component of the player
i mean children
The gun has to be a child of the player prefab that is being instantiated with PhotonNetwork.Instantiate if the gun doesn't rotate or anything, then it should not need it's own photonview
but the gun must be part of the player prefab
?
I have to put the photon viewer
On the camera
For the gun to rotate
Cuz the gun is a child of the camera
Big brain
I think
Lmao
Unrelated problem: Make sure that if you put the camera on the player prefab it is disabled on awake or start if !photonView.isMine... you don't need more than one active camera in the scene
You want to do call and you can screen share?
Im only disabling the component
Not the whole camera object
We can still get its rotation
I never disabled the transform
hrmm, yea.
If the gun has it's own photonView, and the rotation is checked, it should be syncing that with other players
I will try
Btw
Works very bad
It should look like this
I will look at the internet
In pun2, the doc says playerlist are sorted
How is it sorted?
Based on ascending actor number?
I would assume, but not sure
funny eyes
@weak plinth If you want to just rotate gun of the character, just sync the character's look input
And apply it on the other side
lookvector, movevector
your character should be controlled by two vectors
@weak plinth
maybe some bools too : attack, jump, etc
if it's local player, you determine the inputs from keyboard/mouse and send them in stream
if it's not a local player, you get the inputs from stream
@weak plinth
I used to sync inputs for all visual stuff on characters
It will also sync your animator pretty good in most of the cases if you have animation
is netcode and transport both separate networking layers or do I need both, or just one? quick glance at netcode suggests its a server authoritative layer which I want
well, a server model which id assume as authoritative while the transport is used for the FPS stuff so a more peer session based
HI all, I'm new to PUN2, I was just fooling around but I tested calling PhotonNetwork.JoinRandomRoom (and skipping the call to PhotonNetwork.ConnectUsingSettings), which threw an error message
*JoinRandomRoom failed. Client is on MasterServer (must be Master Server for matchmaking) but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
*
Question is - Error message says Client is on MasterServer... this is a little confusing, How can i be on the master server when i have not even connected, e.g using ConnectUsingSettings() ?
Why are you skipping connect using settings?
[PunRPC]
void damage(float amount){
RaycastHit shotHit;
if (Physics.Raycast (new Ray (transform.position, cam.transform.forward), out shotHit, 100)) {
shotHit.collider.gameObject.GetComponent<life> ().hp -= amount;
}
}
i mean it speaks for itself. when this method is called the error shown here is returned, and well the hp is not subtracted(im not sure if it is because of the error or because of me really at this point).
im not even sure if the content really works when this error is returned
How do you call that rpc?
Show me the code u calling
if (Input.GetMouseButton (0)) {
currentTime = timeToShoot; // irrelevant
pv.RPC ("pAnim", RpcTarget.AllBuffered, "shot"); // irrelevant
pv.RPC ("damage", RpcTarget.AllBuffered, 1);
}
was it because i forgot the f?
No, I thought of different parameters. Is the photonview from a parent gameobject or is the photonview on the same as the script the code is from?
same as the script's code is from
Mh did you tried putting f behind the number? I don't think thats a problem but a try^^
Uf ok
How much refresh rate is good for server?
Less as possible
15 FPS ish?
Big question
Probably even more
Not sure what is the approach to scale this
Any solution to limit bandwidth?
Compression
Suppose using some occlusion trick to can minimize it
like not getting datas which aren't in screen
That will help a lot yes
what if my screen have more unit?
Epic does this on fortnite
For RTS it's not impossible to have 1000+ unit in my screen
how to handle that?
Non-static object side worries me
Also RAM side is something to consider
You only replicate state changes
And resolve them on your client
- compression
- data relevancy based on your viewport
Will help
But you probably can’t do that on all your systems
we can resolve stuffs to the point like ordering point A to B
then just use delta time/time to get the pos in real time
if we do that physics side worries me a bit
will server and client match the time properly or not
Not perfectly
You don’t lock your fps on the client
That is the worst thing to do
You just set a tick rate to your server
That handle data replication
And input
Then you resolve the state changes on your client
Your server doesn’t need to run at the same rate as the client
And yeah it’s not perfect
Does game cause problem when going more than 60 fps?
I can’t answer that
As far as I know animation and render side can be smooth but the thing that worries me most is physics and network side
RTS are done with determinism
You only send player inputs, tied.to a fixed tick rate.
Almost all RTS are done like this, you do not send game state at all
You need a deterministic simulation.
One rare exception is planet annihilation, which uses a custom method they call curves
You will not be able.to write a proper RTS with 1000s of units using unitys current netcode...
Possible to do with "custom" netcode?
Heard determinism(another name for lockstep simulation?) has desync and a bit too much strict?
has desync?
I mean, if you know what you are doing, determinism IS the way to go.
And also gives you a whole lot of features out of the box...
Lockstep simulation is ONE type of simulation that requires determinism (so it's not that determinism is another name - lockstep is one way of using determinism to achieve synchronicity).
But you also have deterministic predict/rollback, which gamers and press call Rollback Netcode
- and both lockstep and predict/rollback can be server-mediated, so you avoid the most common issues with pure P2P lockstep.
If you want to do an proper RTS, the way to go is to use determinism... 99% of them do this... As I said, there are a few (very few) exceptions.
Most of the famous RTS that I know of are all lockstep simulations (RTSs do not use predict/rollback)
There's a whole world around determinism that a lot of people is unaware of. I attribute this due to two main factors:
- prevalence of the FPS genre in popular games, and that led to the development of the state-transfer strategies commonly associated as "netcode",
- lockstepping (the first original strategy involving determinism) does not work for action games.
But... It really depends on what you want to do...
You can (probably) develop a super neat custom solution (like the one I mentioned: planet annihilation chrono-cam curves model), but that would take you a LOOOOG time...:)
planet annihilation isn't deterministic? Well first time hearing about this deterministic model...
Planet annihilation is NOT, AFAIK
Pretta much all other are...
Starcraft (1 and 2) is deterministic (so it is heroes of the storm)
LOL (not an RTS though) is determinsitic on server (for it's advantages like storing replays for auditing, etc), but uses a custom state transfer method for the clients
But LOL is not an RTS, as said.
Almost all fighting games that have a (good) online netcode are deterministic
GGPO is the most common (very basic) predict/rollback base library for p2p 1v1 games.
As I said, there's a whole world around determinism... Although I do not have confirmation of this, AFAIK, racing games are also another common genre in that determinism is used (requires confirmation).