Space Plunder
Loading...
Searching...
No Matches
UALSAnimNotifyFootstep Class Reference

#include <ALSAnimNotifyFootstep.h>

Inheritance diagram for UALSAnimNotifyFootstep:

Public Attributes

TObjectPtr< UDataTable > HitDataTable
 
FName FootSocketName = NAME_Foot_R
 
TEnumAsByte< ETraceTypeQuery > TraceChannel
 
TEnumAsByte< EDrawDebugTrace::Type > DrawDebugType
 
float TraceLength = 50.0f
 
bool bSpawnDecal = false
 
bool bMirrorDecalX = false
 
bool bMirrorDecalY = false
 
bool bMirrorDecalZ = false
 
bool bSpawnSound = true
 
FName SoundParameterName = NAME_FootstepType
 
EALSFootstepType FootstepType = EALSFootstepType::Step
 
bool bOverrideMaskCurve = false
 
float VolumeMultiplier = 1.0f
 
float PitchMultiplier = 1.0f
 
bool bSpawnNiagara = false
 

Static Public Attributes

static FName NAME_Foot_R
 
static FName NAME_FootstepType
 

Private Member Functions

virtual void Notify (USkeletalMeshComponent *MeshComp, UAnimSequenceBase *Animation, const FAnimNotifyEventReference &EventReference) override
 
virtual FString GetNotifyName_Implementation () const override
 

Detailed Description

Character footstep anim notify

Member Function Documentation

◆ GetNotifyName_Implementation()

FString UALSAnimNotifyFootstep::GetNotifyName_Implementation ( ) const
overrideprivatevirtual
173{
174 FString Name(TEXT("Footstep Type: "));
176 return Name;
177}
static FORCEINLINE FString GetEnumerationToString(const Enumeration InValue)
Definition ALSCharacterEnumLibrary.h:19
EALSFootstepType FootstepType
Definition ALSAnimNotifyFootstep.h:65

◆ Notify()

void UALSAnimNotifyFootstep::Notify ( USkeletalMeshComponent * MeshComp,
UAnimSequenceBase * Animation,
const FAnimNotifyEventReference & EventReference )
overrideprivatevirtual
25{
26 Super::Notify(MeshComp, Animation, EventReference);
27
28 if (!MeshComp)
29 {
30 return;
31 }
32
33 AActor* MeshOwner = MeshComp->GetOwner();
34 if (!MeshOwner)
35 {
36 return;
37 }
38
39 if (HitDataTable)
40 {
41 UWorld* World = MeshComp->GetWorld();
42 check(World);
43
44 const FVector FootLocation = MeshComp->GetSocketLocation(FootSocketName);
45 const FRotator FootRotation = MeshComp->GetSocketRotation(FootSocketName);
46 const FVector TraceEnd = FootLocation - MeshOwner->GetActorUpVector() * TraceLength;
47
48 FHitResult Hit;
49
50 if (UKismetSystemLibrary::LineTraceSingle(MeshOwner /*used by bIgnoreSelf*/, FootLocation, TraceEnd, TraceChannel, true /*bTraceComplex*/, MeshOwner->Children,
51 DrawDebugType, Hit, true /*bIgnoreSelf*/))
52 {
53 if (!Hit.PhysMaterial.Get())
54 {
55 return;
56 }
57
58 const EPhysicalSurface SurfaceType = Hit.PhysMaterial.Get()->SurfaceType;
59
60 check(IsInGameThread());
61 checkNoRecursion();
62 static TArray<FALSHitFX*> HitFXRows;
63 HitFXRows.Reset();
64
65 HitDataTable->GetAllRows<FALSHitFX>(FString(), HitFXRows);
66
67 FALSHitFX* HitFX = nullptr;
68 if (auto FoundResult = HitFXRows.FindByPredicate([&](const FALSHitFX* Value)
69 {
70 return SurfaceType == Value->SurfaceType;
71 }))
72 {
73 HitFX = *FoundResult;
74 }
75 else if (auto DefaultResult = HitFXRows.FindByPredicate([&](const FALSHitFX* Value)
76 {
77 return EPhysicalSurface::SurfaceType_Default == Value->SurfaceType;
78 }))
79 {
80 HitFX = *DefaultResult;
81 }
82 else
83 {
84 return;
85 }
86
87 if (bSpawnSound && HitFX->Sound.LoadSynchronous())
88 {
89 UAudioComponent* SpawnedSound = nullptr;
90
91 const float MaskCurveValue = MeshComp->GetAnimInstance()->GetCurveValue(
93 const float FinalVolMult = bOverrideMaskCurve
95 : VolumeMultiplier * (1.0f - MaskCurveValue);
96
97 switch (HitFX->SoundSpawnType)
98 {
100 SpawnedSound = UGameplayStatics::SpawnSoundAtLocation(
101 World, HitFX->Sound.Get(), Hit.Location + HitFX->SoundLocationOffset,
102 HitFX->SoundRotationOffset, FinalVolMult, PitchMultiplier);
103 break;
104
106 SpawnedSound = UGameplayStatics::SpawnSoundAttached(HitFX->Sound.Get(), MeshComp, FootSocketName,
107 HitFX->SoundLocationOffset,
108 HitFX->SoundRotationOffset,
109 HitFX->SoundAttachmentType, true, FinalVolMult,
111
112 break;
113 }
114 if (SpawnedSound)
115 {
116 SpawnedSound->SetIntParameter(SoundParameterName, static_cast<int32>(FootstepType));
117 }
118 }
119
120 if (bSpawnNiagara && HitFX->NiagaraSystem.LoadSynchronous())
121 {
122 UNiagaraComponent* SpawnedParticle = nullptr;
123 const FVector Location = Hit.Location + MeshOwner->GetTransform().TransformVector(
124 HitFX->DecalLocationOffset);
125
126 switch (HitFX->NiagaraSpawnType)
127 {
129 SpawnedParticle = UNiagaraFunctionLibrary::SpawnSystemAtLocation(
130 World, HitFX->NiagaraSystem.Get(), Location, FootRotation + HitFX->NiagaraRotationOffset);
131 break;
132
134 SpawnedParticle = UNiagaraFunctionLibrary::SpawnSystemAttached(
135 HitFX->NiagaraSystem.Get(), MeshComp, FootSocketName, HitFX->NiagaraLocationOffset,
136 HitFX->NiagaraRotationOffset, HitFX->NiagaraAttachmentType, true);
137 break;
138 }
139 }
140
141 if (bSpawnDecal && HitFX->DecalMaterial.LoadSynchronous())
142 {
143 const FVector Location = Hit.Location + MeshOwner->GetTransform().TransformVector(
144 HitFX->DecalLocationOffset);
145
146 const FVector DecalSize = FVector(bMirrorDecalX ? -HitFX->DecalSize.X : HitFX->DecalSize.X,
147 bMirrorDecalY ? -HitFX->DecalSize.Y : HitFX->DecalSize.Y,
148 bMirrorDecalZ ? -HitFX->DecalSize.Z : HitFX->DecalSize.Z);
149
150 UDecalComponent* SpawnedDecal = nullptr;
151 switch (HitFX->DecalSpawnType)
152 {
154 SpawnedDecal = UGameplayStatics::SpawnDecalAtLocation(
155 World, HitFX->DecalMaterial.Get(), DecalSize, Location,
156 FootRotation + HitFX->DecalRotationOffset, HitFX->DecalLifeSpan);
157 break;
158
160 SpawnedDecal = UGameplayStatics::SpawnDecalAttached(HitFX->DecalMaterial.Get(), DecalSize,
161 Hit.Component.Get(), NAME_None, Location,
162 FootRotation + HitFX->DecalRotationOffset,
163 HitFX->DecalAttachmentType,
164 HitFX->DecalLifeSpan);
165 break;
166 }
167 }
168 }
169 }
170}
const FName NAME_Mask_FootstepSound(TEXT("Mask_FootstepSound"))
bool bSpawnSound
Definition ALSAnimNotifyFootstep.h:58
bool bMirrorDecalX
Definition ALSAnimNotifyFootstep.h:49
FName SoundParameterName
Definition ALSAnimNotifyFootstep.h:62
FName FootSocketName
Definition ALSAnimNotifyFootstep.h:34
bool bSpawnNiagara
Definition ALSAnimNotifyFootstep.h:77
bool bOverrideMaskCurve
Definition ALSAnimNotifyFootstep.h:68
float TraceLength
Definition ALSAnimNotifyFootstep.h:43
bool bMirrorDecalY
Definition ALSAnimNotifyFootstep.h:52
float PitchMultiplier
Definition ALSAnimNotifyFootstep.h:74
bool bMirrorDecalZ
Definition ALSAnimNotifyFootstep.h:55
bool bSpawnDecal
Definition ALSAnimNotifyFootstep.h:46
float VolumeMultiplier
Definition ALSAnimNotifyFootstep.h:71
TObjectPtr< UDataTable > HitDataTable
Definition ALSAnimNotifyFootstep.h:30
TEnumAsByte< ETraceTypeQuery > TraceChannel
Definition ALSAnimNotifyFootstep.h:37
TEnumAsByte< EDrawDebugTrace::Type > DrawDebugType
Definition ALSAnimNotifyFootstep.h:40
Definition ALSCharacterStructLibrary.h:272

Member Data Documentation

◆ bMirrorDecalX

bool UALSAnimNotifyFootstep::bMirrorDecalX = false

◆ bMirrorDecalY

bool UALSAnimNotifyFootstep::bMirrorDecalY = false

◆ bMirrorDecalZ

bool UALSAnimNotifyFootstep::bMirrorDecalZ = false

◆ bOverrideMaskCurve

bool UALSAnimNotifyFootstep::bOverrideMaskCurve = false

◆ bSpawnDecal

bool UALSAnimNotifyFootstep::bSpawnDecal = false

◆ bSpawnNiagara

bool UALSAnimNotifyFootstep::bSpawnNiagara = false

◆ bSpawnSound

bool UALSAnimNotifyFootstep::bSpawnSound = true

◆ DrawDebugType

TEnumAsByte<EDrawDebugTrace::Type> UALSAnimNotifyFootstep::DrawDebugType

◆ FootSocketName

FName UALSAnimNotifyFootstep::FootSocketName = NAME_Foot_R

◆ FootstepType

EALSFootstepType UALSAnimNotifyFootstep::FootstepType = EALSFootstepType::Step

◆ HitDataTable

TObjectPtr<UDataTable> UALSAnimNotifyFootstep::HitDataTable

◆ NAME_Foot_R

FName UALSAnimNotifyFootstep::NAME_Foot_R
static

◆ NAME_FootstepType

FName UALSAnimNotifyFootstep::NAME_FootstepType
static

◆ PitchMultiplier

float UALSAnimNotifyFootstep::PitchMultiplier = 1.0f

◆ SoundParameterName

FName UALSAnimNotifyFootstep::SoundParameterName = NAME_FootstepType

◆ TraceChannel

TEnumAsByte<ETraceTypeQuery> UALSAnimNotifyFootstep::TraceChannel

◆ TraceLength

float UALSAnimNotifyFootstep::TraceLength = 50.0f

◆ VolumeMultiplier

float UALSAnimNotifyFootstep::VolumeMultiplier = 1.0f

The documentation for this class was generated from the following files: