Collision box bigger than visual component

I’m learning Unreal engine and now I’ve just started with collisions

I have this class constructor:

APaddle::APaddle()
{
 	// 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;

	// Our root component will be a box that reacts to physics and to interact with physical world.
	BoxComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxComponent"));
	RootComponent = BoxComponent;
	BoxComponent->InitBoxExtent(FVector(200.0f, 200.0f, 200.0f));

	// Create and position a mesh component so we can see where our paddle is.
	PaddleVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PaddleVisualRepresentation"));
	PaddleVisual->SetupAttachment(RootComponent);

	SetActorEnableCollision(true);
	
	BoxComponent->SetCollisionProfileName(TEXT("BlockAll")); // or BoxComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);

	// Add a visual cuboid to see it.
	static ConstructorHelpers::FObjectFinder<UStaticMesh> CuboidVisualAsset(TEXT("/Engine/EditorMeshes/EditorCube.EditorCube"));
	if (CuboidVisualAsset.Succeeded())
	{
		PaddleVisual->SetStaticMesh(CuboidVisualAsset.Object);
		static ConstructorHelpers::FObjectFinder<UMaterial> GreenGrassMaterial (TEXT("/Game/Materials/M_Grass.M_Grass"));
		if (GreenGrassMaterial.Succeeded())
		{
			PaddleVisual->SetMaterial(0, GreenGrassMaterial.Object);
		}
	}

	// Take control of the default player
	AutoPossessPlayer = EAutoReceiveInput::Player0;

	// Create an instance of our movement component, and tell it to update our root component.
	OurMovementComponent = CreateDefaultSubobject<UPaddleMovementComponent>(TEXT("PaddleCustomMovementComponent"));
	OurMovementComponent->UpdatedComponent = RootComponent;
}

That make the box appears like this:

117068-collision-box-bigger-than.png

As you can see the BoxComponent is bigger than the visual component.

Is there any way to make both have the same size?

I’m doing everything with C++.

You need to get the dimensions of your cube, and the length, width, and height of your cube seem to be 200. Declare a float store that value there. If you intend on keeping this object as a perfect cube, you will just need one variable, since length, width, and height will all be the same. If you intend on messing around with the dimensions, declare three variables to store the values for your length width and height.

//For cube
float paddleLength = 200.0f;
BoxComponent->InitBoxExtent(FVector(paddleLength, paddleLength, paddleLength));


//For something other than a perfect cube
float paddleLength = 200.0f;
float paddleWidth = 150.0f;
float paddleHeight = 180.0f;
BoxComponent->InitBoxExtent(FVector(paddleLength, paddleWidth, paddleHeight));

Choose ONE of the options I presented you with in that snippet of code. Get the collision box component, and plug those variables into the dimensions of the collision box. If you change the dimensions of the box, the collision box will change accordingly as well. I’m not incredibly familiar with C++, so forgive me for not knowing how to get the component. I’m assuming you are familiar with it, so I trust that you will be able to get the collision box.

If anything is unclear, let me know,

This is because you are extending the collision box from the origin and you need to use the half of the side of the static mesh.