public void ApplyServerInput(PhysicsInputState e) { DLog.Log(string.Format("ApplyingServerInput for player {1} - frame: {0}", e.frame, e.onlineIndex)); Vector2 input = e.inputDir; r.AddForce(new Vector3(input.x, 0f, input.y) * moveSpeed); }
public void ApplyLocalInput(int frame) { if (!localInputs.ContainsKey(frame)) { return; } PhysicsInputState e = localInputs[frame]; DLog.Log(string.Format("Applying local input {1}- frame: {0}", e.frame, e.onlineIndex)); Vector2 input = e.inputDir; r.AddForce(new Vector3(input.x, 0f, input.y) * moveSpeed); }
/// <summary> /// this applies all inputs recieved by the server. /// </summary> /// <param name="frame"></param> public void ApplyPhysicsInputState(int frame) { if (playerInputs.ContainsKey(frame)) { for (int i = 0; i < playerInputs[frame].Count; i++) { PhysicsInputState s = playerInputs[frame][i]; NetworkedBubbleControllerBehaviour.players[s.onlineIndex].ApplyServerInput(s); } } else { //Debug.LogError("Cant apply physics input state because this frame {" + frame + "} has no data!!"); //this happens because we don't start keeping track of inputs input a few second after the server starts, //so we never have inputs for serverFrame = 0, safe to just ignore. } }