How do I add an actorcomponent to pawn, docs and google are confusing

Hi,
This is probably embarassingly simple, but I am so lost in my googling and the outdated posts/documentation have completely thrown me for a loop.

Here’s the situation:
I have created a UActorComponent in the c++ class wizard from the editor, let’s call it UPawnSteeringComponent. I want to create an instance, register it and attach it via c++ to the pawn.

How do I make this happen? I know it’s all done in the pawn, I tried so many different ways of NewObject etc, but I would just love a straight forward example of how this is done, please and thank you.

Hello, in your header file of your character:

  1. #include “PawnSteeringComponent.h” right before the generated.h

  2. Create the following uproperty:

    UPROPERTY(VisibleAnywhere)

    UPawnSteeringComponent* ActorComp;

then. switch to your source file and in your constructor type in the following line:

ActorComp = CreateDefaultSubobject<UPawnSteeringComponent>(TEXT("MyActorCompName"));

-Orfeas

Thank you! Sorry for the delay, the notifications are always weird here.