Hello, happy New Year everybody… I’m developing a server for a small online game, it’s a like topdown game but the camera is moved back a little to create perspective.
I’d like some suggession’s for the server… Currently I plan to make authoritative everything other than movement, this will just be broadcasted as the client sent it(maybe add some very very basic check’s before applying it.). Is this a reasonable approach?
Also what is the approach to check shooting on the server? I don’t need full simulation and accurate calculations as this game is casual and does not pretend to be realistic but I want to prevent someone sending packet saing “I killed everybody” something like that :).
PS I’m currently using Photon from ExitGames as a server.
Doesn’t Photon have all their own syntax and code to do this stuff, or when you use photon do you still use unity’s networking code?
No I don’t use unity’s networking code and Photon is only the tool to connect client’s it doesn’t know anything about the game.
So you’re not using Unity’s networking code, and Photon only allows you to connect clients… so how are you going to do all the nitty gritty stuff like instantiating and syncing objects across the network?
Photon send’s events to unity and tells it what to display and Unity just renders what I want…
Ahh I see, sorry I’ve never used a 3rd party server solution, just the built-in networking stuff. Wouldn’t your question be better served in a photon forum? Not to be rude, I just haven’t seen much photon info around these parts.
I’m not asking for some code samples or something dependant to Photon, just mentioned that I use it not built-in networking…
Questions are pretty generic and do apply to any server technology…
Ah I see… sorry for the confusion. I was actually going to post some code samples on how I do things authoritatively, which is why I was confused, lol.
So yeah, your general concept seems sound.
Authoritative shooting is kind of a pain in the nuts, if you don’t want the client’s experience to be laggy as hell, at least in my experience. Basically I do whatever it is the act of “shooting” is locally for the client (non-networked), like create a muzzle flash, shoot a raycast, and instantiate a spark prefab on the point of collision (but does no damage logic or anything to what he hits).
At the same time, that client sends a message to the server that he fired a shot, and the server tells everyone else to create the muzzle flash, and the server calculates the shot raycast, sees if it hit another player, and if it did, tells all the clients that he was hit, and reduces his health for everyone.
Thanks for answer… But what about movement? Will this be a problem if it’ll be full trust? Or just go back to it whan I’d face cheating problem?(hopefully would
)
BTW don’t know why but I can’t get the feeling of the “world” on the server… 
I actually don’t do movement authoritatively, simply because in my game, the possibility gaining an advantage through the great lengths it would take to actually modify the movement packets is pretty much nil.
I just let the client do his own movement, and let him sync his position/rotation to everyone else.
However, I imagine if you did it authoritatively, it would be similar to my shooting example. You wouldn’t want the client to have to send a movement request and wait for the server to update his position because there would undoubtedly be input lag, so you’d probably have him move himself locally, tell the server to move him for everyone else, and then have the server tell him where he is, and then on the client, interpolate the difference between where his local movement put him and where the server’s movement put him (only if they’re different … I would think).
I think I would send position from client and just broadcast it to all game players and apply some kind of interpolation to hide the latency…
As I thought no need to do this authoritatively…
And for shooting i’ll just use your method, i’ll just trust the client for the shooting and just check for damage. And use unity’s physics so the bullet will spawn a decal when hit or something else… Only critical things like demage, money, items will be most secured…
Technically, I’m not trusting the client with anything, I’m letting the client shoot locally just to give the illusion that his gun is firing immediately when he fires, but the bullets in his instance of the game are basically just for show, and don’t do anything; the raycast that occurs in the server’s instance of the game when the client fires his weapon is what is really going to calculate damage, and then the server tells all the clients what the client firing his weapon hit.
Also thought that i’ll need level geometry to do level raycast… so I’ll need something to export level geometry and load this on server… and than i’d do the raycast based on this geometry…
Hey Viktor.
Why did you choose Photon instead of Unity’s built in networking ?