Description

Adding a dynamic binding and preforming a hot reload sometimes causes the binding to not be registered by class/blueprint instances that already exist in the world. Instances need to be replaced from the Content Browser after the hot reload to register the updating binding.

Repro Rate:
4/10

Regression:
No - same behavior occurs with 4.16.3 (CL 3561208)

Steps to Reproduce
  1. Open UE4 Editor (any project)
  2. Add code based on Actor (MyActor)
  3. Add the following to MyActor.h
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
    		class UBoxComponent* _box;
    
    	UFUNCTION(BlueprintCallable, Category = test)
    		void OnBoxOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
    
  4. Add the following to MyActor.cpp:
    • Add with other #include:
      #include "Runtime/Engine/Classes/Components/BoxComponent.h"
      #include "Engine.h"
      
    • Add to AMyActor::AMyActor():
      _box = CreateDefaultSubobject<UBoxComponent>(TEXT("MyBox"));
      	_box->OnComponentBeginOverlap.AddDynamic(this, &AMyActor::OnBoxOverlapBegin);
      
    • Add at the bottom of the .cpp file:
      void AMyActor::OnBoxOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
      {
      	if (GEngine)
      	{
      		GEngine->AddOnScreenDebugMessage(-1, 4.f, FColor::MakeRandomColor(), TEXT("Enter"));
      	}
      }
      
  5. Compile
  6. Add instance of MyActor class to the viewport
  7. Add the following to MyActor.h:
    UFUNCTION(BlueprintCallable, Category = test)
    		void OnBoxOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
    
  8. Add the following to MyActor.cpp
    • Add to AMyActor::AMyActor():
      _box->OnComponentEndOverlap.AddDynamic(this, &AMyActor::OnBoxOverlapEnd);
      
    • Add at the bottom of the .cpp file:
      void AMyActor::OnBoxOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
      {
      	if (GEngine)
      	{
      		GEngine->AddOnScreenDebugMessage(-1, 4.f, FColor::MakeRandomColor(), TEXT("Exit"));
      	}
      }
      
  9. Compile with the editor open
  10. PIE

Result:
The instance placed in step 6 will have the BeginOverlap text (Enter) print but the EndOverlap text (Exit) does not print

Expected:
Placed instances update dynamic binding that is added/hot reloaded

Have Comments or More Details?

Head over to the existing Questions & Answers thread and let us know what's up.

1
Login to Vote

Cannot Reproduce
CreatedOct 6, 2017
ResolvedOct 9, 2017
UpdatedJul 14, 2021
View Jira Issue