diff --git a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.cpp b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.cpp index 7936919f..88ba64fb 100644 --- a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.cpp +++ b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.cpp @@ -3,6 +3,7 @@ #include "Feedback/ContextEffects/GBFContextEffectsInterface.h" #include "Feedback/ContextEffects/GBFContextEffectsLibrary.h" #include "Feedback/ContextEffects/GBFContextEffectsSubsystem.h" +#include "NiagaraComponent.h" #include #include @@ -51,10 +52,11 @@ void UGBFAnimNotify_ContextEffects::Notify( USkeletalMeshComponent * mesh_comp, if ( bPerformTrace ) { // If trace is needed, set up Start Location to Attached - auto trace_start = bAttached ? mesh_comp->GetSocketLocation( SocketName ) : mesh_comp->GetComponentLocation(); - auto offset_rotation = bAttached ? mesh_comp->GetSocketRotation( SocketName ) : mesh_comp->GetComponentRotation(); + const auto offset_start_location = bAttached ? mesh_comp->GetSocketLocation( SocketName ) : mesh_comp->GetComponentLocation(); + const auto offset_rotation = bAttached ? mesh_comp->GetSocketRotation( SocketName ) : mesh_comp->GetComponentRotation(); - auto trace_end = trace_start + offset_rotation.RotateVector( TraceProperties.EndTraceLocationOffset ); + const auto trace_start = offset_start_location + offset_rotation.RotateVector( TraceProperties.StartTraceLocationOffset ); + const auto trace_end = offset_start_location + offset_rotation.RotateVector( TraceProperties.EndTraceLocationOffset ); // Make sure World is valid if ( auto * world = owning_actor->GetWorld() ) @@ -109,6 +111,7 @@ void UGBFAnimNotify_ContextEffects::Notify( USkeletalMeshComponent * mesh_comp, hit_result, contexts, VFXProperties.Scale, + static_cast< bool >( VFXProperties.bOnlyOwnerSee ), AudioProperties.VolumeMultiplier, AudioProperties.PitchMultiplier } ); } @@ -179,7 +182,8 @@ void UGBFAnimNotify_ContextEffects::Notify( USkeletalMeshComponent * mesh_comp, // Cycle through Niagara Systems and call Spawn System Attached, passing in relevant data for ( auto * niagara_system : total_niagara_systems ) { - UNiagaraFunctionLibrary::SpawnSystemAttached( niagara_system, mesh_comp, ( bAttached ? SocketName : FName( "None" ) ), LocationOffset, RotationOffset, VFXProperties.Scale, EAttachLocation::KeepRelativeOffset, true, ENCPoolMethod::None, true, true ); + auto * niagara_component = UNiagaraFunctionLibrary::SpawnSystemAttached( niagara_system, mesh_comp, ( bAttached ? SocketName : FName( "None" ) ), LocationOffset, RotationOffset, VFXProperties.Scale, EAttachLocation::KeepRelativeOffset, true, ENCPoolMethod::None, true, true ); + niagara_component->SetOnlyOwnerSee( VFXProperties.bOnlyOwnerSee ); } } } @@ -203,11 +207,13 @@ void UGBFAnimNotify_ContextEffects::SetParameters( const FGameplayTag effect_in, LocationOffset = location_offset_in; RotationOffset = rotation_offset_in; VFXProperties.Scale = vfx_properties_in.Scale; + VFXProperties.bOnlyOwnerSee = vfx_properties_in.bOnlyOwnerSee; AudioProperties.PitchMultiplier = audio_properties_in.PitchMultiplier; AudioProperties.VolumeMultiplier = audio_properties_in.VolumeMultiplier; bAttached = attached_in; SocketName = socket_name_in; bPerformTrace = perform_trace_in; + TraceProperties.StartTraceLocationOffset = trace_properties_in.StartTraceLocationOffset; TraceProperties.EndTraceLocationOffset = trace_properties_in.EndTraceLocationOffset; TraceProperties.TraceChannel = trace_properties_in.TraceChannel; TraceProperties.bIgnoreActor = trace_properties_in.bIgnoreActor; diff --git a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsComponent.cpp b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsComponent.cpp index 5fdf6990..777c0ed6 100644 --- a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsComponent.cpp +++ b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsComponent.cpp @@ -1,6 +1,7 @@ #include "Feedback/ContextEffects/GBFContextEffectsComponent.h" #include "Feedback/ContextEffects/GBFContextEffectsSubsystem.h" +#include "NiagaraComponent.h" #include #include @@ -108,7 +109,20 @@ void UGBFContextEffectsComponent::AnimMotionEffect_Implementation( const FGBFCon TArray< UNiagaraComponent * > niagara_components; // Spawn effects - context_effects_subsystem->SpawnContextEffects( GetOwner(), context_effect_infos.StaticMeshComponent, context_effect_infos.Bone, context_effect_infos.LocationOffset, context_effect_infos.RotationOffset, context_effect_infos.MotionEffect, total_contexts, audio_components, niagara_components, context_effect_infos.VfxScale, context_effect_infos.AudioVolume, context_effect_infos.AudioPitch ); + context_effects_subsystem->SpawnContextEffects( + GetOwner(), + context_effect_infos.StaticMeshComponent, + context_effect_infos.Bone, + context_effect_infos.LocationOffset, + context_effect_infos.RotationOffset, + context_effect_infos.MotionEffect, + total_contexts, + audio_components, + niagara_components, + context_effect_infos.VfxScale, + context_effect_infos.bOnlyOwnerSee, + context_effect_infos.AudioVolume, + context_effect_infos.AudioPitch ); // Append resultant effects audio_components_to_add.Append( audio_components ); diff --git a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsInterface.cpp b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsInterface.cpp index 375f0b84..e830a5b6 100644 --- a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsInterface.cpp +++ b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsInterface.cpp @@ -27,6 +27,7 @@ FGBFContextEffectInfos::FGBFContextEffectInfos( const FHitResult & hit_result, const FGameplayTagContainer & contexts, const FVector & vfx_scale, + const bool only_owner_see, const float audio_volume, const float audio_pitch ) : @@ -40,6 +41,7 @@ FGBFContextEffectInfos::FGBFContextEffectInfos( HitResult( hit_result ), Contexts( contexts ), VfxScale( vfx_scale ), + bOnlyOwnerSee( only_owner_see ), AudioVolume( audio_volume ), AudioPitch( audio_pitch ) { diff --git a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsSubsystem.cpp b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsSubsystem.cpp index 57f2d5e8..33f46fc6 100644 --- a/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsSubsystem.cpp +++ b/Source/GameBaseFramework/Private/Feedback/ContextEffects/GBFContextEffectsSubsystem.cpp @@ -1,6 +1,7 @@ #include "Feedback/ContextEffects/GBFContextEffectsSubsystem.h" #include "Feedback/ContextEffects/GBFContextEffectsLibrary.h" +#include "NiagaraComponent.h" #include #include @@ -16,6 +17,7 @@ void UGBFContextEffectsSubsystem::SpawnContextEffects( const AActor * spawning_a TArray< UAudioComponent * > & audio_out, TArray< UNiagaraComponent * > & niagara_out, const FVector vfx_scale, + const bool only_owner_see, const float audio_volume, const float audio_pitch ) { @@ -66,6 +68,7 @@ void UGBFContextEffectsSubsystem::SpawnContextEffects( const AActor * spawning_a { // Spawn Niagara Systems Attached, add Niagara Component to List of NCs auto * niagara_component = UNiagaraFunctionLibrary::SpawnSystemAttached( niagara_system, attach_to_component, attach_point, location_offset, rotation_offset, vfx_scale, EAttachLocation::KeepRelativeOffset, true, ENCPoolMethod::None, true, true ); + niagara_component->SetOnlyOwnerSee( only_owner_see ); niagara_out.Add( niagara_component ); } } diff --git a/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.h b/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.h index 70b83602..5a540497 100644 --- a/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.h +++ b/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFAnimNotify_ContextEffects.h @@ -14,6 +14,10 @@ struct GAMEBASEFRAMEWORK_API FGBFContextEffectAnimNotifyVFXSettings // Scale to spawn the particle system at UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = FX ) FVector Scale = FVector( 1.0f, 1.0f, 1.0f ); + + // Whether only the owner can see the VFX or everyone + UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = FX ) + uint8 bOnlyOwnerSee : 1; }; USTRUCT( BlueprintType ) @@ -39,6 +43,10 @@ struct GAMEBASEFRAMEWORK_API FGBFContextEffectAnimNotifyTraceSettings UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = Trace ) TEnumAsByte< ECollisionChannel > TraceChannel = ECollisionChannel::ECC_Visibility; + // Vector offset from Effect start Location + UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = Trace ) + FVector StartTraceLocationOffset = FVector::ZeroVector; + // Vector offset from Effect Location UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = Trace ) FVector EndTraceLocationOffset = FVector::ZeroVector; diff --git a/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFContextEffectsInterface.h b/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFContextEffectsInterface.h index e9fdfef1..e41c6fe9 100644 --- a/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFContextEffectsInterface.h +++ b/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFContextEffectsInterface.h @@ -31,6 +31,7 @@ struct FGBFContextEffectInfos const FHitResult & hit_result, const FGameplayTagContainer & contexts, const FVector & vfx_scale = FVector( 1 ), + const bool only_owner_see = false, float audio_volume = 1, float audio_pitch = 1 ); @@ -64,6 +65,9 @@ struct FGBFContextEffectInfos UPROPERTY( EditAnywhere ) FVector VfxScale = FVector( 1 ); + UPROPERTY( EditAnywhere ) + uint8 bOnlyOwnerSee : 1; + UPROPERTY( EditAnywhere ) float AudioVolume = 1; diff --git a/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFContextEffectsSubsystem.h b/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFContextEffectsSubsystem.h index 0353c6b8..b89031a4 100644 --- a/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFContextEffectsSubsystem.h +++ b/Source/GameBaseFramework/Public/Feedback/ContextEffects/GBFContextEffectsSubsystem.h @@ -49,6 +49,7 @@ class GAMEBASEFRAMEWORK_API UGBFContextEffectsSubsystem : public UWorldSubsystem TArray< UAudioComponent * > & audio_out, TArray< UNiagaraComponent * > & niagara_out, FVector vfx_scale = FVector( 1 ), + const bool only_owner_see = false, float audio_volume = 1, float audio_pitch = 1 );