Download

Hit.IsValidBlockingHit is always returning false

I was trying to make a code for when you hit a collider the pawn walks to one of the sides. For this I created a class that extends UPawnMovementComponent to be used in conjunction with my Pawn. For some reason, Hit.IsValidBlockingHit () always results in false, even when I collide with something and bSweep as true is not preventing my pawn from crossing colliders as it should be.

Does anyone know what can it be?


void UColliderMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)

{

Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

// Check to make sure everyting is still valid and that we are allowed to move

if (!PawnOwner || !UpdatedComponent || ShouldSkipUpdate(DeltaTime))

{

return;

}

FVector DesiredMovementThisFrame = ConsumeInputVector().GetClampedToMaxSize(1.f) * DeltaTime * 150.f;

if (!DesiredMovementThisFrame.IsNearlyZero())

{

FHitResult Hit;

SafeMoveUpdatedComponent(DesiredMovementThisFrame, UpdatedComponent->GetComponentRotation(),true, Hit);

UE_LOG(LogTemp, Warning, TEXT("DesiredMovementThisFrame: %s"), *DesiredMovementThisFrame.ToString());

//if we bump into something, slide along the side of it

if (Hit.IsValidBlockingHit())

{

UE_LOG(LogTemp, Warning, TEXT("Hit %s"), *Hit.ImpactPoint.ToString());

SlideAlongSurface(DesiredMovementThisFrame, 1.f - Hit.Time, Hit.Normal, Hit);

}

}

}