I have created a C++ class with these two components:
#include "Paddle.h"
#include <Components/BoxComponent.h>
#include <Components/StaticMeshComponent.h>
// Sets default values
APaddle::APaddle()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp"));
// Disable collision.
MeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
// Set the first object in the hierachy.
RootComponent = MeshComp;
CollisionComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionComp"));
// No physics, queries only.
CollisionComponent->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
CollisionComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
// It will generate the 'Hit' event.
CollisionComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Block);
CollisionComponent->SetupAttachment(MeshComp);
}
I’m going to use the CollisionComponent to detect collisions.
I have created a Blueprint class using that C++ class. On the Blueprint editor I have added set it a Static Mesh to the MeshComp.
Now I’m trying to make that the CollisionComponent has the same size as the MeshComp but it is very hard:
Is there anyway to make it automatically? Something like: hey, CollisionComponet, you and MeshComp you have to have the same size.
