I’m learning Unreal and now I’m trying to understand how collisions work.
I have created an empty C++ project with the default map and added a class that I can move with keyboard. When I move it I have found that my Pawn can go through the floor:
My Pawn constructor is:
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.
UBoxComponent* BoxComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxComponent"));
RootComponent = BoxComponent;
// Create and position a mesh component so we can see where our sphere is.
UStaticMeshComponent* MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PaddleVisualRepresentation"));
MeshComponent->SetupAttachment(RootComponent);
// Add a visual cuboid to see it.
static ConstructorHelpers::FObjectFinder<UStaticMesh> CuboidVisualAsset(TEXT("/Engine/EditorMeshes/EditorCube.EditorCube"));
if (CuboidVisualAsset.Succeeded())
{
MeshComponent->SetStaticMesh(CuboidVisualAsset.Object);
static ConstructorHelpers::FObjectFinder<UMaterial> GreenGrassMaterial (TEXT("/Game/Materials/M_Grass.M_Grass"));
if (GreenGrassMaterial.Succeeded())
{
MeshComponent->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;
}
How can avoid it?