private void CheckPlayerDirection(float angle) { if (angle >= 315f && angle <= 360f || angle >= 0f && angle <= 45f) { playerSprites.CmdChangeDirection(Vector2.up); //Prediction playerSprites.FaceDirection(Vector2.up); } if (angle > 45f && angle <= 135f) { playerSprites.CmdChangeDirection(Vector2.right); //Prediction playerSprites.FaceDirection(Vector2.right); } if (angle > 135f && angle <= 225f) { playerSprites.CmdChangeDirection(Vector2.down); //Prediction playerSprites.FaceDirection(Vector2.down); } if (angle > 225f && angle < 315f) { playerSprites.CmdChangeDirection(Vector2.left); //Prediction playerSprites.FaceDirection(Vector2.left); } }
private Vector3Int GetMoveDirection(MatrixInfo matrixInfo, bool isReplay) { Vector3Int direction = Vector3Int.zero; for (int i = 0; i < moveActionList.Count; i++) { direction += GetMoveDirection(moveActionList[i]); } direction.x = Mathf.Clamp(direction.x, -1, 1); direction.y = Mathf.Clamp(direction.y, -1, 1); // Logger.LogTrace(direction.ToString(), Category.Movement); if ((PlayerManager.LocalPlayer == gameObject || isServer) && !isReplay) { playerSprites.FaceDirection(Orientation.From(direction.To2Int())); } if (matrixInfo.MatrixMove) { // Converting world direction to local direction direction = Vector3Int.RoundToInt(matrixInfo.MatrixMove.ClientState.RotationOffset.EulerInverted * direction); } return(direction); }
private Vector3Int GetMoveDirection(MatrixInfo matrixInfo, bool isReplay) { Vector3Int direction = Vector3Int.zero; for (int i = 0; i < pressedKeys.Count; i++) { direction += GetMoveDirection(pressedKeys[i]); } direction.x = Mathf.Clamp(direction.x, -1, 1); direction.y = Mathf.Clamp(direction.y, -1, 1); Logger.Log(direction.ToString(), Category.Movement); if (!isGhost && PlayerManager.LocalPlayer == gameObject && !isReplay) { playerSprites.CmdChangeDirection(Orientation.From(direction)); // Prediction: playerSprites.FaceDirection(Orientation.From(direction)); } if (matrixInfo.MatrixMove) { // Converting world direction to local direction direction = Vector3Int.RoundToInt(matrixInfo.MatrixMove.ClientState.Orientation.EulerInverted * direction); } return(direction); }