Author Topic: Sending Input to Dedicated Server  (Read 3170 times)

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Sending Input to Dedicated Server
« 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sending Input to Dedicated Server
« Reply #1 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().

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: Sending Input to Dedicated Server
« Reply #2 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sending Input to Dedicated Server
« Reply #3 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.

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: Sending Input to Dedicated Server
« Reply #4 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?

  1. // Client sends direction to server
  2. // Host is acting as the dedicated server
  3. tno.SendQuickly(2, Target.Host, angle);
  4.  
  5. // Server sends current position to everybody
  6. tno.SendQuickly(1, Target.OthersSaved, pos);
  7.  



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sending Input to Dedicated Server
« Reply #5 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".

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: Sending Input to Dedicated Server
« Reply #6 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sending Input to Dedicated Server
« Reply #7 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?