Tasharen Entertainment Forum
Support => TNet 3 Support => Topic started by: LuffyGray on March 21, 2017, 10:37:23 AM
-
Quick question, what options are available for backend calculations such as physics, authoritive positioning, collision, pathfinding etc?
Additionally if it ends up being a headless client option for such calculations, what would be the best option for multiple dynamic rooms or would you have to run a headless client for each room?
Thank you.
-
Physics and pathfinding are game code, while TNet is a network communication and serialization library. I always recommend keeping your game code on the client side. Headless clients for games is the traditional old Unity networking approach, and it doesn't scale well at all. In Windward I was able to have over 300 concurrent players at one point, connected to my home computer playing without issues using about 5% CPU while I continued working on the game at the same time and played alongside them. Doing this with headless clients would use an insane amount of resources in comparison. Ask yourself if you really need such authoritative approach. In 99% of the cases the answer would be "no".
-
Physics and pathfinding are game code, while TNet is a network communication and serialization library. I always recommend keeping your game code on the client side. Headless clients for games is the traditional old Unity networking approach, and it doesn't scale well at all. In Windward I was able to have over 300 concurrent players at one point, connected to my home computer playing without issues using about 5% CPU while I continued working on the game at the same time and played alongside them. Doing this with headless clients would use an insane amount of resources in comparison. Ask yourself if you really need such authoritative approach. In 99% of the cases the answer would be "no".
In regards to that, how would you personally handle these aspecs;
A) Pathfinding for AI in a persistent multiplayer game where AI will go for the player closest to it so if there are 2 players and the AI is surrounding both who are moving around each other?
B) Handling collisions such as a car hitting a player, won't it be easily hacked to disallow the collision if its client authoritive.
C) Physics, once the player is hit by the car, how to deal with the physics?
I did think that maybe leaving the physics as client authoritive for local entities but simply lerping between positions for remote entities if need be.
Thank you for your time.
-
A) I would have one player -- the channel's host -- do the pathfinding logic for both players. Players would say "I want to move to XYZ". The host would get this RFC and perform a pathfinding check on a separate thread. At the end of the check I'd fire an RFC back to everyone with the calculated path. All clients would then execute the movement using this path. Corrections to the path will also be done the same way -- host player detects a collision on the path and that causes it to recalculate the path and re-send the result to everyone.
B) Player side for sure. Hacked, yes -- but there are a bazillion ways to hack a game, and unless you're making World of Warcraft, you really should worry about making a great game first. If you are worried about hackers so early on in the game's lifetime, consider integrating an actual anti-cheat solution into your game. You're trying to fix a client side problem on the server side, instead of trying to fix it on the client side where it exists. We've had a few discussions about anti-cheating on this forum actually -- with some good suggestions all around.
C) React same way as single player. One player, generally one that owns (controls) the car will send the result of the collision to everyone else, saying "I collided at this position with this velocity, and this is the result" -- something to that extent. Although I don't bother even with that in Sightseer. I just let physics be completely local, and the corrections are sent out periodically by the players that control the cars on a regular interval. Input is sync'd frequently. Clients move cars based on input. Rigidbody pos/rot/velocity is sync'd every ~2 seconds or so, causing other clients to either snap or smoothly tween to the corrected values.