RTS camera blocking

Hello world!
I am trying to create RTS game with RTS Camera Movament. I’m using this tutorial : [UE4 C++] RTS Camera Edge Panning/Scrolling - YouTube
But I don’t have any idea how to create Camera XY Limits (when you scroll to map border, camera don’t go farther ) Please help my with this. I use c++

Hey there, you can define a minimum maximum X and Y for the camera to be a certain value and you can clamp it after you change the position of the camera.

Could you write this code. taht is what I have now ;
CameraPawn.cpp

// Fill out your copyright notice in the Description page of Project Settings.

#include "CameraPawn.h"
#include "gal4.h"
#include "GameFramework/PlayerController.h"



// Sets default values
ACameraPawn::ACameraPawn()
{
 	// Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	RootScene = CreateDefaultSubobject<USceneComponent>(TEXT("RootScene"));
	RootComponent = RootScene;

	SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
	SpringArm->SetupAttachment(RootScene);
	SpringArm->bDoCollisionTest = false;
	SpringArm->SetRelativeRotation(FRotator(-50, 0, 0));

	CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
	CameraComp->SetupAttachment(SpringArm);



}

// Called when the game starts or when spawned
void ACameraPawn::BeginPlay()
{
	Super::BeginPlay();

	PC = Cast<APlayerController>(GetController());
	PC->GetViewportSize(ScreenSizeX, ScreenSizeY); 
}

// Called every frame
void ACameraPawn::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	AddActorWorldOffset(GetCameraPanDirection() * CamSpeed);

}

FVector ACameraPawn::GetCameraPanDirection()
{
	float MousePosX;
	float MousePosY;
	float CamDirectionX = 0;
	float CamDirectionY = 0;

	PC->GetMousePosition(MousePosX, MousePosY);	
	
	if (MousePosX <= Margin)
	{
		CamDirectionY = -1;
	}

	if (MousePosY <= Margin)
	{
		CamDirectionX = 1;
	}

	if (MousePosX >= ScreenSizeX - Margin)
	{
		CamDirectionY = 1;
	}

	if (MousePosY >= ScreenSizeY - Margin)
	{
		CamDirectionX = -1;
	}

	return FVector(CamDirectionX, CamDirectionY, 0); 
}

CameraPawn.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"

#include "CameraPawn.generated.h"

UCLASS()
class GAL4_API ACameraPawn : public APawn
{
	GENERATED_BODY()

public:
	// Sets default values for this pawn's properties
	ACameraPawn();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override
	{
		Super::SetupPlayerInputComponent(PlayerInputComponent);

	}

	UPROPERTY()
	USceneComponent* RootScene;
	
	UPROPERTY()
	USpringArmComponent* SpringArm;

	UPROPERTY()
	UCameraComponent* CameraComp;

	UPROPERTY()
	APlayerController* PC;

	UFUNCTION()
	FVector GetCameraPanDirection();

	UPROPERTY()
	float Margin = 15;

	UPROPERTY()
	int32 ScreenSizeX; 
	
	UPROPERTY()
	int32 ScreenSizeY;

	UPROPERTY()
	float CamSpeed = 110; 
};

Write my this code for blocking camera.

What do you mean?