Download

Set no collision to Pawn's visual component

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?

Short answer: This is completely fine. Since you disabled collision for the visual component anyway, its object type can be anything, really.

Longer answer: A component’s object type determines if other components can collide with it and if so, whether they should produce blocking hits or overlaps. It’s part of the “collision matrix” that you see in the collision settings.

In the image above, if I didn’t want this actor to collide with any pawns, I’d check the “Ignore” box under “Object Responses”. How does the engine know what is a pawn and what isn’t? By looking at a component’s object type. That’s what it does, but it doesn’t have any effect on components where collision is disabled anyway.

Thanks. I understand your short answer, but I don’t your long answer.