diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/GrabBehavior.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/GrabBehavior.cpp index 502a4be532df57e6f3214e859db8eb4729b15482..c62cfb45d3fa787ad981b1bb6a0917e4f36758e5 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/GrabBehavior.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/GrabBehavior.cpp @@ -23,6 +23,12 @@ void UGrabBehavior::BeginPlay() OnActionReplicationStartedOriginatorEvent.AddDynamic(this, &UGrabBehavior::ReplicationOriginaterClientCallback); } +void UGrabBehavior::EndPlay(const EEndPlayReason::Type EndPlayReason) +{ + Super::EndPlay(EndPlayReason); + OnActionReplicationStartedOriginatorEvent.RemoveDynamic(this, &UGrabBehavior::ReplicationOriginaterClientCallback); +} + UPrimitiveComponent* UGrabBehavior::GetFirstComponentSimulatingPhysics(const AActor* TargetActor) { TArray<UPrimitiveComponent*> PrimitiveComponents; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/GrabBehavior.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/GrabBehavior.h index 65118646b4ca6edae19772cb3d5bf1df875534ee..bdf29ee7106965f75e952266e5e1f2cea7387a29 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/GrabBehavior.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/GrabBehavior.h @@ -44,6 +44,7 @@ public: UPrimitiveComponent* MyPhysicsComponent; virtual void BeginPlay() override; + virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; UPrimitiveComponent* GetFirstComponentSimulatingPhysics(const AActor* TargetActor);