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:
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++.