void FixedUpdate() { bool[] inputs = new bool[6]; inputs[0] = Input.GetKey(KeyCode.W); inputs[1] = Input.GetKey(KeyCode.A); inputs[2] = Input.GetKey(KeyCode.S); inputs[3] = Input.GetKey(KeyCode.D); inputs[4] = Input.GetKey(KeyCode.Space); inputs[5] = Input.GetMouseButton(0); yaw += Input.GetAxis("Mouse X") * sensitivityX; pitch += Input.GetAxis("Mouse Y") * sensitivityY; Quaternion rotation = Quaternion.Euler(pitch, yaw, 0); PlayerInputData inputData = new PlayerInputData(inputs, rotation, GameManager.Instance.LastRecievedServerTick - 1); transform.position = interpolation.CurrentData.Position; PlayerStateData nextStateData = playerLogic.GetNextFrameData(inputData, interpolation.CurrentData); interpolation.SetFramePosition(nextStateData); using (Message message = Message.Create((ushort)Tags.GamePlayerInput, inputData)) { ConnectionManager.Instance.Client.SendMessage(message, SendMode.Reliable); } }
void FixedUpdate() { if (IsOwn) { bool[] inputs = new bool[6]; inputs[0] = Input.GetKey(KeyCode.W); inputs[1] = Input.GetKey(KeyCode.A); inputs[2] = Input.GetKey(KeyCode.S); inputs[3] = Input.GetKey(KeyCode.D); inputs[4] = Input.GetKey(KeyCode.Space); inputs[5] = Input.GetMouseButton(0); if (inputs[5]) { GameObject go = Instantiate(ShotPrefab); go.transform.position = Interpolation.CurrentData.Position; go.transform.rotation = transform.rotation; Destroy(go, 1f); } yaw += Input.GetAxis("Mouse X") * SensitivityX; pitch += Input.GetAxis("Mouse Y") * SensitivityY; Quaternion rot = Quaternion.Euler(pitch, yaw, 0); PlayerInputData inputData = new PlayerInputData(inputs, rot, GameManager.Instance.LastRecievedServerTick - 1); transform.position = Interpolation.CurrentData.Position; PlayerUpdateData updateData = Logic.GetNextFrameData(inputData, Interpolation.CurrentData); Interpolation.SetFramePosition(updateData); using (Message m = Message.Create((ushort)Tags.GamePlayerInput, inputData)) { GlobalManager.Instance.Client.SendMessage(m, SendMode.Reliable); } reconciliationHistory.Enqueue(new ReconciliationInfo(GameManager.Instance.ClientTick, updateData, inputData)); } }