Skip to content

Context effects start offset #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Feedback/ContextEffects/GBFContextEffectsInterface.h"
#include "Feedback/ContextEffects/GBFContextEffectsLibrary.h"
#include "Feedback/ContextEffects/GBFContextEffectsSubsystem.h"
#include "NiagaraComponent.h"

#include <Components/SkeletalMeshComponent.h>
#include <Engine/World.h>
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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 } );
}
Expand Down Expand Up @@ -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 );
}
}
}
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Feedback/ContextEffects/GBFContextEffectsComponent.h"

#include "Feedback/ContextEffects/GBFContextEffectsSubsystem.h"
#include "NiagaraComponent.h"

#include <Engine/World.h>
#include <PhysicalMaterials/PhysicalMaterial.h>
Expand Down Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) :

Expand All @@ -40,6 +41,7 @@ FGBFContextEffectInfos::FGBFContextEffectInfos(
HitResult( hit_result ),
Contexts( contexts ),
VfxScale( vfx_scale ),
bOnlyOwnerSee( only_owner_see ),
AudioVolume( audio_volume ),
AudioPitch( audio_pitch )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Feedback/ContextEffects/GBFContextEffectsSubsystem.h"

#include "Feedback/ContextEffects/GBFContextEffectsLibrary.h"
#include "NiagaraComponent.h"

#include <Kismet/GameplayStatics.h>
#include <NiagaraFunctionLibrary.h>
Expand All @@ -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 )
{
Expand Down Expand Up @@ -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 );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -64,6 +65,9 @@ struct FGBFContextEffectInfos
UPROPERTY( EditAnywhere )
FVector VfxScale = FVector( 1 );

UPROPERTY( EditAnywhere )
uint8 bOnlyOwnerSee : 1;

UPROPERTY( EditAnywhere )
float AudioVolume = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
Loading