Using sweep in AddWorldOffset() prevents any movement

Hello,

I’ve recently begun working on my custom character controller (yes, I know unreal has a built in one which is perfectly fine, I want to build my own, please refrain from commenting on that, that’s not the topic here, cheers). After doing some calculations I’m using AddWorldOffset on RootComponent of the Actor my MovementComponent is attached to:

void UPTMovementComponent::BeginPlay()
{
	Super::BeginPlay();

	RootComponent = Cast<UPrimitiveComponent>(GetOwner()->GetRootComponent());

RootComponent->AddWorldOffset(MovementVector);

However, my Character doesn’t collide with anything despite using Pawn collision preset and other objects using WorldStatic collision preset. I’ve figured it’s because of lack of sweeping, so I changed the latter to:

RootComponent->AddWorldOffset(MovementVector, true);

But then the character stops moving at all. However, I also have a method added to OnComponentBeginOverlap, which just logs some text, and the function doesn’t trigger… Any ideas what I’ve done wrong?

For questions like this it’s faster to debug by yourself using breakpoints in Visual Studio and see first if AddWorldOffset() get called. Then step into the function and see if something cause it return early.

It’s possible that your actor hasn’t been initialized properly due to your custom character script.