Support => TNet 3 Support => Topic started by: djray2k on March 19, 2014, 01:54:37 PM
Title: Sending Input to Dedicated Server
Post by: djray2k on March 19, 2014, 01:54:37 PM
I want to send a byte to represent angle of direction. The server will do the game logic and send back position as a Vector3. It's for sports game that would require real time position/rotation of all the players. I know how to apply prediction and smoothing algorithms.
How often should I send input from a client to the server per second? How often should I send positions from a server to the clients per second? Should I use UDP to send information like this? If so, how do I enable UDP?
Title: Re: Sending Input to Dedicated Server
Post by: ArenMook on March 20, 2014, 02:39:38 AM
1. Not that often. Rely on your prediction instead, and actually send the data when it changes instead. 2. This isn't up to you. Server will send the data when it receives it from the clients. 3. Ideally, yes. StartUDP().
Title: Re: Sending Input to Dedicated Server
Post by: djray2k on March 20, 2014, 10:17:59 AM
Thanks for the reply!
1 and 3, got it.
2, I'm lost now. I'm fairly new to this and I've never done a dedicated server before. I test by having one instance run as a server, and then 2+ instances run as clients. All the server instance does is the logic, and then I send back the data of the position/rotation from the server instance the exact same way I send the input from the clients.
Is there a different/better way of doing this that I'm missing?
Title: Re: Sending Input to Dedicated Server
Post by: ArenMook on March 20, 2014, 01:16:07 PM
Client sends data whenever you deem it necessary. Server immediately echoes that data to all requested targets.
Title: Re: Sending Input to Dedicated Server
Post by: djray2k on March 21, 2014, 02:46:05 PM
Are you saying that's what I should do, or what the server is doing automatically?
For example when a client sends an angle of direction to the server, is that being sent to all the clients as well?
// Client sends direction to server
// Host is acting as the dedicated server
tno.SendQuickly(2, Target.Host, angle);
// Server sends current position to everybody
tno.SendQuickly(1, Target.OthersSaved, pos);
Title: Re: Sending Input to Dedicated Server
Post by: ArenMook on March 21, 2014, 05:00:26 PM
You are confusing the terms "host" and "server".
Server is like a post office. It receives letters from various sources and forwards them to the correct destination. You can't send messages to the server just like you can't send letters to a post office -- only to other people. You send messages through the server, just like you send letters through a post office. Get it?
Host is just another player. Every channel designates one player to be the "host". This player is considered to be the authoritative player for the sake of determining who's game state should be "correct" when there is conflicting data.
When you send a message via Target.Host, it simply means "send it to the player who's considered to be more important than everyone else in the room".
Title: Re: Sending Input to Dedicated Server
Post by: djray2k on April 01, 2014, 04:05:26 PM
Ah, I see now. I've been playing around with it some more and I understand it now. Thanks.
Another quick question. For sending user input (direction), should I use an RFC call for that? It needs to be sent as much as possible.
Title: Re: Sending Input to Dedicated Server
Post by: ArenMook on April 02, 2014, 06:51:47 PM
"It needs to be sent as much as possible" <-- not sure what this means
Yes, use RFCs to send data. You always use RFCs to send data. What else would you use?