Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sephirot47/2b9883d1d7d1a3feb4b3 to your computer and use it in GitHub Desktop.
Save sephirot47/2b9883d1d7d1a3feb4b3 to your computer and use it in GitHub Desktop.
UE4 OnBeginOverlap - OnEndOverlap (Collision stuff)
// For Components =================================
UFUNCTION()
void OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
UFUNCTION()
void OnEndOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
// Register events in BeginPlay
OnComponentBeginOverlap.AddDynamic(this, &MyClass::OnBeginOverlap); //Register the BeginOverlap event
OnComponentEndOverlap.AddDynamic(this, &MyClass::OnEndOverlap); //Register the EndOverlap event
// =================================================
// For Actors =================================
UFUNCTION()
void OnBeginOverlap(AActor* ThisActor, AActor* OtherActor);
UFUNCTION()
void OnEndOverlap(AActor* ThisActor, AActor* OtherActor);
// Register events in BeginPlay
OnActorBeginOverlap.AddDynamic(this, &MyClass::OnBeginOverlap);
OnActorEndOverlap.AddDynamic(this, &MyClass::OnEndOverlap);
// =================================================
@Cyclotron555
Copy link

Thanks. Registering the events in the constructor doesn't work anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment