Using sweep in AddWorldOffset() prevents any movement

JackxBlack
Sun, 17 Oct 2021 09:41:07 +0000
Rendering

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?

2 posts - 1 participant