diff --git a/Source/GameBaseFramework/Private/Animation/GBFAnimNotify_GameplayCueLooping.cpp b/Source/GameBaseFramework/Private/Animation/GBFAnimNotify_GameplayCueLooping.cpp index 24d78d3d..bc6af840 100644 --- a/Source/GameBaseFramework/Private/Animation/GBFAnimNotify_GameplayCueLooping.cpp +++ b/Source/GameBaseFramework/Private/Animation/GBFAnimNotify_GameplayCueLooping.cpp @@ -9,8 +9,35 @@ void UGBFAnimNotify_GameplayCueLooping::NotifyBegin( USkeletalMeshComponent * me if ( owning_actor != nullptr && GameplayCueTag.GetTagName() != NAME_None ) { - Parameters.TargetAttachComponent = mesh_component; - UGameplayCueFunctionLibrary::AddGameplayCueOnActor( owning_actor, GameplayCueTag, Parameters ); + FGameplayCueParameters gameplay_cue_parameters; + + if ( bUseLineTraceToFillParameters ) + { + FHitResult hit_result; + + const auto trace_start_location = owning_actor->GetActorLocation(); + const auto trace_end_location = owning_actor->GetActorLocation() + LineTraceVector; + + FCollisionQueryParams collision_params; + collision_params.bReturnPhysicalMaterial = bGatherPhysicalMaterial; + collision_params.AddIgnoredActor( owning_actor ); + + owning_actor->GetWorld()->LineTraceSingleByChannel( hit_result, trace_start_location, trace_end_location, TraceCollisionChannel, collision_params ); + + if ( bGatherPhysicalMaterial ) + { + gameplay_cue_parameters.PhysicalMaterial = hit_result.PhysMaterial; + } + + if ( bGatherTraceHitPointLocation ) + { + gameplay_cue_parameters.Location = hit_result.Location; + gameplay_cue_parameters.Normal = hit_result.Normal; + } + } + + gameplay_cue_parameters.TargetAttachComponent = mesh_component; + UGameplayCueFunctionLibrary::AddGameplayCueOnActor( owning_actor, GameplayCueTag, gameplay_cue_parameters ); } } @@ -22,7 +49,8 @@ void UGBFAnimNotify_GameplayCueLooping::NotifyEnd( USkeletalMeshComponent * mesh if ( owning_actor != nullptr && GameplayCueTag.GetTagName() != NAME_None ) { - Parameters.TargetAttachComponent = mesh_component; - UGameplayCueFunctionLibrary::RemoveGameplayCueOnActor( owning_actor, GameplayCueTag, Parameters ); + FGameplayCueParameters gameplay_cue_parameters; + gameplay_cue_parameters.TargetAttachComponent = mesh_component; + UGameplayCueFunctionLibrary::RemoveGameplayCueOnActor( owning_actor, GameplayCueTag, gameplay_cue_parameters ); } } \ No newline at end of file diff --git a/Source/GameBaseFramework/Public/Animation/GBFAnimNotify_GameplayCueLooping.h b/Source/GameBaseFramework/Public/Animation/GBFAnimNotify_GameplayCueLooping.h index b564a802..206a6b15 100644 --- a/Source/GameBaseFramework/Public/Animation/GBFAnimNotify_GameplayCueLooping.h +++ b/Source/GameBaseFramework/Public/Animation/GBFAnimNotify_GameplayCueLooping.h @@ -2,7 +2,6 @@ #include #include -#include #include "GBFAnimNotify_GameplayCueLooping.generated.h" @@ -21,6 +20,21 @@ class GAMEBASEFRAMEWORK_API UGBFAnimNotify_GameplayCueLooping final : public UAn UPROPERTY( EditAnywhere, Category = "GameplayCue", meta = ( Categories = "GameplayCue", AllowPrivateAccess ) ) FGameplayTag GameplayCueTag; - UPROPERTY( EditAnywhere, Category = "GameplayCue", meta = ( Categories = "GameplayCue", AllowPrivateAccess ) ) - FGameplayCueParameters Parameters; + UPROPERTY( EditAnywhere, Category = "Parameters", meta = ( AllowPrivateAccess ) ) + bool bUseLineTraceToFillParameters = false; + + /* Line trace will start at actor location */ + UPROPERTY( EditAnywhere, Category = "Parameters", meta = ( AllowPrivateAccess, EditCondition = "bUseLineTraceToFillParameters" ) ) + FVector LineTraceVector; + + UPROPERTY( EditAnywhere, Category = "Parameters", meta = ( AllowPrivateAccess, EditCondition = "bUseLineTraceToFillParameters" ) ) + TEnumAsByte< ECollisionChannel > TraceCollisionChannel; + + /* keep line trace hit point physical material, usefull for gameplay cue's surfaces spawn conditions */ + UPROPERTY( EditAnywhere, Category = "Parameters", meta = ( AllowPrivateAccess, EditCondition = "bUseLineTraceToFillParameters" ) ) + uint8 bGatherPhysicalMaterial : 1; + + /* will override attachment gameplay cue position*/ + UPROPERTY( EditAnywhere, Category = "Parameters", meta = ( AllowPrivateAccess, EditCondition = "bUseLineTraceToFillParameters" ) ) + uint8 bGatherTraceHitPointLocation : 1; };