x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

UBoxComponent SetBoxExtent make it invisible

When i use SetBoxExtent on a UBoxComponent, it seem to change extents in the outliner detail, and the overlaps trigger as they should, but the UBoxComponent goes invisible in the editor. What am i missing?

Ladder.h:

 UCLASS()
 class OMICRON_API ALadder : public AActor
 {
     GENERATED_BODY()
     
 private:
     UPROPERTY(VisibleAnywhere, Category = "Components")
     class USceneComponent * SceneComponent;
 
     UPROPERTY(VisibleAnywhere, Category = "Components")
     class UBoxComponent * DetectionBox;
 
     UPROPERTY(EditAnywhere, Category = "Settings", Meta = (MakeEditWidget = true))
     FVector DetectionBoxSize = FVector(-10.0f, 10.0f, 100.0f);
 
 public:    
     ALadder();
 
 protected:
 #if WITH_EDITOR 
     virtual void PostEditChangeProperty(FPropertyChangedEvent & PropertyChangedEvent);
 #endif
 
     virtual void BeginPlay() override;
 
 public:    
     virtual void Tick(float DeltaTime) override;
 
     UFUNCTION()
     void OnOverlapBegin(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
 
     UFUNCTION()
     void OnOverlapEnd(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex);
 
 private:
     UFUNCTION()
     void UpdateLadder();
 };

Ladder.cpp:

 ALadder::ALadder()
 {
     PrimaryActorTick.bCanEverTick = false;
 
     SceneComponent = CreateAbstractDefaultSubobject<USceneComponent>(TEXT("Scene Component"));
     RootComponent = SceneComponent;
 
     DetectionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("Detection Box"));
     DetectionBox->AttachToComponent(SceneComponent, FAttachmentTransformRules::KeepRelativeTransform);
     DetectionBox->OnComponentBeginOverlap.AddDynamic(this, &ALadder::OnOverlapBegin);
     DetectionBox->OnComponentEndOverlap.AddDynamic(this, &ALadder::OnOverlapEnd);
 
     UpdateLadder();
 }
 
 #if WITH_EDITOR 
 void ALadder::PostEditChangeProperty(FPropertyChangedEvent & PropertyChangedEvent)
 {
     UpdateLadder();
 }
 #endif
 
 void ALadder::BeginPlay()
 {
     Super::BeginPlay();    
 }
 
 void ALadder::Tick(float DeltaTime)
 {
     Super::Tick(DeltaTime);
 }
 
 void ALadder::OnOverlapBegin(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
 {
     UE_LOG(LogTemp, Warning, TEXT("begin"));
 }
 
 void ALadder::OnOverlapEnd(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex)
 {
     UE_LOG(LogTemp, Warning, TEXT("end"));
 }
 
 void ALadder::UpdateLadder()
 {
     DetectionBox->SetBoxExtent(FVector(FMath::Abs(DetectionBoxSize.X), FMath::Abs(DetectionBoxSize.Y), FMath::Abs(DetectionBoxSize.Z / 2)), true);
     DetectionBox->SetRelativeLocation(FVector(0, 0, DetectionBoxSize.Z / 2));
 }
Product Version: UE 4.21
Tags:
more ▼

asked Apr 02 '19 at 03:06 PM in C++ Programming

avatar image

JayZone80
1 1 1

avatar image JayZone80 Apr 03 '19 at 11:42 PM

I just noticed that if i use build on the level, the box shows again! Strange, but not a solution!

avatar image ColdSteel48 Apr 04 '19 at 03:58 AM

Are you using HotReload?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I just realized i had forgot to call the Super in post edit change property! :)

 #if WITH_EDITOR 
 void ALadder::PostEditChangeProperty(FPropertyChangedEvent & PropertyChangedEvent)
 {
     Super::PostEditChangeProperty(PropertyChangedEvent);
 
     UpdateLadder();
 }
 #endif
more ▼

answered Apr 04 '19 at 12:49 PM

avatar image

JayZone80
1 1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question