Skip to content

Commit

Permalink
Added entity motion prediction to client
Browse files Browse the repository at this point in the history
  • Loading branch information
zesterer committed Jul 2, 2018
1 parent 353705c commit 8b1abf8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,18 @@ impl Client {
fn tick(&self, dt: f32) {
if let Some(uid) = self.player().entity_uid {
if let Some(player_entry) = self.entities_mut().get_mut(&uid) {
let move_dir = player_entry.move_dir();
*player_entry.pos_mut() += move_dir * dt;

self.conn.send(ClientMessage::PlayerEntityUpdate {
pos: player_entry.pos(),
move_dir: player_entry.move_dir(),
look_dir: player_entry.look_dir(),
});
}
}

for (uid, entity) in self.entities_mut().iter_mut() {
let move_dir = entity.move_dir();
*entity.pos_mut() += move_dir * dt;
}
}

fn handle_packet(&self, packet: ServerMessage) {
Expand Down

0 comments on commit 8b1abf8

Please sign in to comment.