I’ve just started to learn Unreal Engine 4.26 using C++. To do it, I am developing an Atari’s Pong clone. Now, I’m dealing with Collision.
On my paddle class, that inherits from APawn, I have added a UStaticMeshComponent
as a Visual Component, and a UBoxComponent
used to detect collisions.
To disable any kind of collisions in the VisualComponent
I have used the NoCollision
profile:
CollisionComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("PaddleCollisionComponent"));
VisualComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PaddleVisualComponent"));
RootComponent = CollisionComponent;
// Set up CollisionComponent as parent of VisualComponent;
VisualComponent->SetupAttachment(CollisionComponent);
VisualComponent->BodyInstance.SetCollisionProfileName("NoCollision");
CollisionComponent->BodyInstance.SetCollisionProfileName("Pawn");
CollisionComponent->OnComponentHit.AddDynamic(this, &APaddle::OnHit);
But checking the NoCollision
profile definition, its Object Type
is WorldStatic
but the VisualComponent
is part of a Pawn
, which is not a World Static object.
My question is that I don’t know if this is the right way to set no collision to the Visual Component because it is not a World Static object (or, maybe, I am confuse about object types because I’ve just started to learn Unreal).
How do I set no collision to the Visual Component?