Jump to content
Posted 28 May 2012 - 12:42 AM
Posted 29 May 2012 - 03:09 PM
Edited by Angus Hollands, 30 May 2012 - 02:51 PM.
Posted 30 May 2012 - 06:27 PM
Posted 31 May 2012 - 03:02 AM
Edited by Angus Hollands, 31 May 2012 - 10:32 AM.
Posted 31 May 2012 - 05:33 PM
Purely out of interest, why not RLE the entire packet, if you're sending batched packets anyway? CPU time?
Posted 31 May 2012 - 06:06 PM
Posted 01 June 2012 - 07:45 AM
Edited by Angus Hollands, 01 June 2012 - 09:35 AM.
Posted 01 June 2012 - 12:59 PM
Posted 10 June 2012 - 06:59 AM
Posted 10 June 2012 - 11:35 AM
Im starting on client prediction, but i have to consider a few things. Firstly, are there any good resources for extrapolation of positions and orientations in a fast manner?
Posted 11 June 2012 - 04:42 PM
Posted 11 June 2012 - 06:07 PM
Posted 12 June 2012 - 02:54 AM
Edited by Angus Hollands, 12 June 2012 - 11:55 AM.
Posted 13 June 2012 - 10:42 AM
Posted 13 June 2012 - 01:19 PM
# Updated every network recv tick_rate = 60 network_packet = 6 #tick_0 = ... tick_1 = ... current_tick == ... position_0, orientation_0, velocity_0 = state_0 position_1, orientation_1, velocity_1 = state_1 position_now = user.worldPosition.copy() # Extrapolated (current) position according to tick 0 position_acc_tick_0 = position_0 + velocity_0 * ((tick_now - tick_0) / tick_rate) # Extrapolated (current) position according to tick 1 position_acc_tick_1 = position_1 + velocity_1 * ((tick_now - tick_1) / tick_rate) # Get the error between two predictions as a velocity vector velocity_err = (position_acc_tick_1 - position_acc_tick_0) / ((tick_1 - tick_0) / tick_rate) # Get the estimated position the client needs to be at in one network ticks time, accounting for error position_out = position_acc_tick_1 + velocity_err * ( (tick_now - tick_1 + network_packet) / tick_rate ) # Get's velocity needed to move from current position to target position within one network tick needed_velocity = (position_out - position_now) / (network_packet / tick_rate) # Updated every frame new_velocity = needed_velocity * ((current_tick - packet_tick) / tick_rate)
Edited by Angus Hollands, 13 June 2012 - 03:26 PM.
Posted 13 June 2012 - 04:43 PM
And, another conceptual question!
With rotation of players, Mouselook that was purely server side would be laggy and almost unplayable. Should it be purely client side and transmitted? or would you use something like epic? - I can recreate that for rotations.
Posted 17 June 2012 - 08:06 AM
Posted 17 June 2012 - 01:51 PM
Posted 18 June 2012 - 06:33 PM
def correct_errors(self, gamestate_tick): '''Correct error between prediction and server state @param gamestate_tick: tick to correct from''' # Iterate through all predictions, update to reflect corrections simulated_states = self.simulated_states received_states = self.received_states predicted_state = simulated_states.get(gamestate_tick) received_state = received_states.get(gamestate_tick ) username = self.username # Try to get the user prediction and server determined gamestates try: user_prediction = predicted_state[username] server_data = received_state[username] # If this fails, then return as both states are required except (TypeError, KeyError) as err: return predicted_position, predicted_orientation, predicted_velocity = user_prediction server_position, server_orientation, server_velocity, server_states = server_data # Applies the modification to the predictions position_error = server_position - predicted_position velocity_error = server_velocity - predicted_velocity #position_error # Prevents local and remote collision errors # Update existing user position to reflect packet difference (error) user = self.users.get_user(username) user.object.worldPosition += position_error # Modify predicted state data for tick, state in list(simulated_states.items()): # Ignore & remove old predictions before this gamestate if tick < gamestate_tick: self.simulated_states.pop(tick) continue # Get the data of the local user from the state try: state_position, state_orientation, state_velocity = state[username] except: continue # Get prediction errors corrected_position = state_position + position_error corrected_velocity = state_velocity + velocity_error # Modify the predicted state to reflect corrections state[username] = corrected_position, state_orientation, corrected_velocity
Posted 18 June 2012 - 09:21 PM