Improved network interpolation
This commit is contained in:
@ -21,10 +21,14 @@ func (game *Game) Move(data []byte, address *net.UDPAddr) error {
|
||||
|
||||
player.Position.X = math.Float32frombits(binary.LittleEndian.Uint32(data))
|
||||
player.Position.Z = math.Float32frombits(binary.LittleEndian.Uint32(data[4:]))
|
||||
player.direction.X = math.Float32frombits(binary.LittleEndian.Uint32(data[8:]))
|
||||
player.direction.Z = math.Float32frombits(binary.LittleEndian.Uint32(data[12:]))
|
||||
|
||||
update := []byte(player.ID)
|
||||
update = AppendFloat(update, player.Position.X)
|
||||
update = AppendFloat(update, player.Position.Z)
|
||||
update = AppendFloat(update, player.direction.X)
|
||||
update = AppendFloat(update, player.direction.Z)
|
||||
|
||||
game.BroadcastOthers(PlayerMove, update, player)
|
||||
return nil
|
||||
|
@ -12,6 +12,7 @@ type Player struct {
|
||||
game *Game
|
||||
authToken string
|
||||
address *net.UDPAddr
|
||||
direction Vector3
|
||||
lastPacket time.Time
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user