Struct rusty_sword_arena::game::PlayerInput [−][src]
pub struct PlayerInput { pub id: u8, pub attack: bool, pub move_amount: Vector2, pub direction: f32, }
Clients should send PlayerInput
s to the server ASAP. The quicker the server gets inputs, the
more accurate the simulation will be. But of course, you also shouldn't overload the server
with too much traffic, because that's bad too. Good rule of thumb: Coalesce 4 milliseconds
worth of input together, and send that. That's about 4 times faster than frames are sent by the
server (60fps = 16.7ms). The server should be able to handle ~250 pkts/sec per client. I hope.
Fields
id: u8
The ID of your player
attack: bool
Whether you are attempting to attack (actual attack will occur if the server-side attack timer has reached 0)
move_amount: Vector2
How much your player is attempting to move horizontally (x) and vertically (y) [-1.0, 1.0]. Positive is right and up for x and y, respectively.
direction: f32
What direction your player is facing. You can turn instantly, you lucky dog.
Methods
impl PlayerInput
[src]
impl PlayerInput
pub fn new() -> Self
[src]
pub fn new() -> Self
pub fn coalesce(&mut self, new: PlayerInput)
[src]
pub fn coalesce(&mut self, new: PlayerInput)
Trait Implementations
impl Clone for PlayerInput
[src]
impl Clone for PlayerInput
fn clone(&self) -> PlayerInput
[src]
fn clone(&self) -> PlayerInput
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for PlayerInput
[src]
impl Debug for PlayerInput
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for PlayerInput
[src]
impl PartialEq for PlayerInput
fn eq(&self, other: &PlayerInput) -> bool
[src]
fn eq(&self, other: &PlayerInput) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &PlayerInput) -> bool
[src]
fn ne(&self, other: &PlayerInput) -> bool
This method tests for !=
.
Auto Trait Implementations
impl Send for PlayerInput
impl Send for PlayerInput
impl Sync for PlayerInput
impl Sync for PlayerInput