FIXED: Extent axes were negative which causes only the volume’s origin to hit the trace.
In a brand spankin new project, I’ve got an actor class with a UBoxComponent. Whenever I set the volume’s extent with UBoxComponent::SetBoxExtent() within the actor’s OnConstruction function, traces only hit the volume’s center ((0, 0, 0) relative). If the extent is set anywhere else (I have not yet tested other functions such as PostEditChangeProperty), traces will hit anywhere on the volume.
This seems like a bug, but I probably missed something stupid.
ATestActor.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "TestActor.generated.h"
UCLASS()
class DEVPROJECT_API ATestActor : public AActor {
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ATestActor();
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
class UBoxComponent* Volume;
#if WITH_EDITOR
virtual void OnConstruction(const FTransform& Transform) override;
#endif // WITH_EDITOR
ATestActor.cpp
#include "TestActor.h"
#include "Components/BoxComponent.h"
ATestActor::ATestActor() {
PrimaryActorTick.bCanEverTick = false;
Volume = CreateDefaultSubobject<UBoxComponent>("Box Collision");
// Setting the extent here does not mess with traces; they hit all faces of the volume normally
Volume->SetBoxExtent(FVector(128.f, 128.f, 128.f));
SetRootComponent(Volume);
}
#if WITH_EDITOR
void ATestActor::OnConstruction(const FTransform& Transform) {
Super::OnConstruction(Transform);
Volume->SetRelativeLocation(CenterLocation);
// This causes traces to only hit the volume's origin
Volume->SetBoxExtent(FVector(0.f, YExtent, ZExtent));
}
#endif // WITH_EDITOR
I have also set the root component as a USceneComponent and attached the volume to it. This behavior is still present.