Constructing the Capsule Component

Hi There!!

In this lecture, we construct the capsule component. We declared the capsule component in the previous lecture and now we construct it.

First of all, you need to declare it in the header file like this-

class UCapsuleComponent* CapsuleComp;

I’ve declared it in the private section as the instructor did in the lecture.

And now, include the #include “Components/CapsuleComponent.h” in your CPP file. In the constructor, ABasePawn(), do this-

CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>("Capsule Collider");
RootComponent = CapsuleComp;

This creates the CapsuleComponent. You need to give the type in the angled brackets(<>), and the name in the parentheses. Congratulations! you’ve added the capsule component to your BasePawn.

The second line declares the capsule component as the root component(instead of the USceneComponent).

Unreal Engine -

If you drag your BasePawn, you’ll get something like this. Now, look at my components, it shows the Capsule component in it.

That’s all for now folks. And, please upload the section slides, I’d love to see them after I finish the lecture. And if Stephen Ulibarri is reading this, well, keep the good work! I love the way you teach and make the concepts fit in our brains. I’m going to buy a few courses from you too!!

Previous Toon Tanks post: UCapsuleComponent

Thanks for reading,
Good Bye!!


I’ll look into if we can get the section slides uploaded. @StephenUlibarri keep up the good work!

1 Like

No problem @Kevin-Brandon, I have left that work to @DanM.

1 Like

Sounds good :+1:

1 Like

It does.