Improved network interpolation

This commit is contained in:
2024-02-15 18:06:44 +01:00
parent b439919ad0
commit 2e7b385b46
6 changed files with 22 additions and 18 deletions

View File

@ -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

View File

@ -12,6 +12,7 @@ type Player struct {
game *Game
authToken string
address *net.UDPAddr
direction Vector3
lastPacket time.Time
}