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

#include <AnimNotifyFootstep.h>

Inheritance diagram for UAnimNotifyFootstep:

Public Member Functions

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

Public Attributes

bool bSpawnSound = true
 
float VolumeMultiplier = 1.0f
 
float PitchMultiplier = 1.0f
 
EFootstepType FootstepType = EFootstepType::Step
 
bool bLeftFoot = true
 
bool bRightFoot = false
 

Member Function Documentation

◆ GetNotifyName_Implementation()

FString UAnimNotifyFootstep::GetNotifyName_Implementation ( ) const
overridevirtual
137{
138 FString Foot(TEXT("Right Foot"));
139 if(bLeftFoot)
140 {
141 Foot = (TEXT("Left Foot"));
142 }
143 if(bLeftFoot && bRightFoot)
144 {
145 Foot = (TEXT("Both Feet"));
146 }
147 FString Name(Foot +TEXT("Footstep Type: "));
148 Name.Append(StaticEnum<EFootstepType>()->GetNameStringByValue(static_cast<int64>(FootstepType)));
149 return Name;
150}
bool bLeftFoot
Definition AnimNotifyFootstep.h:36
bool bRightFoot
Definition AnimNotifyFootstep.h:38
EFootstepType FootstepType
Definition AnimNotifyFootstep.h:34

◆ Notify()

void UAnimNotifyFootstep::Notify ( USkeletalMeshComponent * MeshComp,
UAnimSequenceBase * Animation,
const FAnimNotifyEventReference & EventReference )
overridevirtual
11{
12 TRACE_CPUPROFILER_EVENT_SCOPE(UAnimNotifyFootstep::Notify);
13
14 Super::Notify(MeshComp, Animation, EventReference);
15 if(MeshComp == nullptr){return;}
16 const AActor* MeshOwner = MeshComp->GetOwner();
17 if(MeshOwner == nullptr){return;}
18
19 TArray<UActorComponent*> Components = MeshOwner->GetComponentsByInterface(UFootstepInterface::StaticClass());
20 if(Components.IsEmpty()){return;}
21 for(UActorComponent* Component : Components)
22 {
23 IFootstepInterface* FootstepComponent = Cast<IFootstepInterface>(Component);
24 if(Component == nullptr){return;}
25 if(bLeftFoot)
26 {
27 FootstepComponent->PlayFootstepSoundEvent();
28 }
29 if(bRightFoot)
30 {
31 FootstepComponent->PlayFootstepSoundEvent(bRightFoot);
32 }
33 }
34
35 // if(HitDataTable)
36 // {
37 // UWorld* World = MeshComp->GetWorld();
38 // check(World);
39 //
40 // const FVector FootLocation = MeshComp->GetSocketLocation(FootSocketName);
41 // const FRotator FootRotation = MeshComp->GetSocketRotation(FootSocketName);
42 // const FVector TraceEnd = FootLocation - MeshOwner->GetActorUpVector() * TraceLength;
43 // FHitResult Hit;
44 //
45 // if (UKismetSystemLibrary::LineTraceSingle(MeshOwner /*used by bIgnoreSelf*/, FootLocation, TraceEnd, TraceChannel, true /*bTraceComplex*/, MeshOwner->Children,
46 // DrawDebugType, Hit, true /*bIgnoreSelf*/))
47 // {
48 // if(!Hit.PhysMaterial.Get()){return;}
49 //
50 // const EPhysicalSurface SurfaceType = Hit.PhysMaterial.Get()->SurfaceType;
51 // check(IsInGameThread());
52 // checkNoRecursion();
53 // static TArray<FALSHitFX*> HitFXRows;
54 // HitFXRows.Reset();
55 // HitDataTable->GetAllRows<FALSHitFX>(FString(), HitFXRows);
56 // FALSHitFX* HitFX = nullptr;
57 // if (auto FoundResult = HitFXRows.FindByPredicate([&](const FALSHitFX* Value)
58 // {
59 // return SurfaceType == Value->SurfaceType;
60 // }))
61 // {
62 // HitFX = *FoundResult;
63 // }
64 // else if (auto DefaultResult = HitFXRows.FindByPredicate([&](const FALSHitFX* Value)
65 // {
66 // return EPhysicalSurface::SurfaceType_Default == Value->SurfaceType;
67 // }))
68 // {
69 // HitFX = *DefaultResult;
70 // }
71 // else
72 // {
73 // return;
74 // }
75 // if(bSpawnSound && HitFX->Sound.LoadSynchronous())
76 // {
77 // UAudioComponent* SpawnedSound = nullptr;
78 //
79 // const float MaskCurveValue = MeshComp->GetAnimInstance()->GetCurveValue(
80 // NAME_Mask_FootstepSound);
81 // const float FinalVolMult = bOverrideMaskCurve
82 // ? VolumeMultiplier
83 // : VolumeMultiplier * (1.0f - MaskCurveValue);
84 //
85 // switch (HitFX->SoundSpawnType)
86 // {
87 // case EALSSpawnType::Location:
88 // SpawnedSound = UGameplayStatics::SpawnSoundAtLocation(
89 // World, HitFX->Sound.Get(), Hit.Location + HitFX->SoundLocationOffset,
90 // HitFX->SoundRotationOffset, FinalVolMult, PitchMultiplier);
91 // break;
92 //
93 // case EALSSpawnType::Attached:
94 // SpawnedSound = UGameplayStatics::SpawnSoundAttached(HitFX->Sound.Get(), MeshComp, FootSocketName,
95 // HitFX->SoundLocationOffset,
96 // HitFX->SoundRotationOffset,
97 // HitFX->SoundAttachmentType, true, FinalVolMult,
98 // PitchMultiplier);
99 //
100 // break;
101 // }
102 // if(SpawnedSound)
103 // {
104 // SpawnedSound->SetIntParameter(SoundParameterName, static_cast<int32>(FootstepType));
105 // }
106 // }
107 // if (bSpawnNiagara && HitFX->NiagaraSystem.LoadSynchronous())
108 // {
109 // UNiagaraComponent* SpawnedParticle = nullptr;
110 // const FVector Location = Hit.Location + MeshOwner->GetTransform().TransformVector(
111 // HitFX->DecalLocationOffset);
112 //
113 // switch (HitFX->NiagaraSpawnType)
114 // {
115 // case EALSSpawnType::Location:
116 // SpawnedParticle = UNiagaraFunctionLibrary::SpawnSystemAtLocation(
117 // World, HitFX->NiagaraSystem.Get(), Location, FootRotation + HitFX->NiagaraRotationOffset);
118 // break;
119 //
120 // case EALSSpawnType::Attached:
121 // SpawnedParticle = UNiagaraFunctionLibrary::SpawnSystemAttached(
122 // HitFX->NiagaraSystem.Get(), MeshComp, FootSocketName, HitFX->NiagaraLocationOffset,
123 // HitFX->NiagaraRotationOffset, HitFX->NiagaraAttachmentType, true);
124 // break;
125 // }
126 // }
127 // if (bSpawnDecal && HitFX->DecalMaterial.LoadSynchronous())
128 // {
129 // SpawnDecal(Hit);
130 // }
131 // }
132
133 // }
134}
Definition FootstepInterface.h:16
virtual void PlayFootstepSoundEvent(const bool bRightFoot=false, float VolumeMultiplier=1.0f, float PitchMultiplier=1.0f)=0
virtual void Notify(USkeletalMeshComponent *MeshComp, UAnimSequenceBase *Animation, const FAnimNotifyEventReference &EventReference) override
Definition AnimNotifyFootstep.cpp:9

Member Data Documentation

◆ bLeftFoot

bool UAnimNotifyFootstep::bLeftFoot = true

◆ bRightFoot

bool UAnimNotifyFootstep::bRightFoot = false

◆ bSpawnSound

bool UAnimNotifyFootstep::bSpawnSound = true

◆ FootstepType

EFootstepType UAnimNotifyFootstep::FootstepType = EFootstepType::Step

◆ PitchMultiplier

float UAnimNotifyFootstep::PitchMultiplier = 1.0f

◆ VolumeMultiplier

float UAnimNotifyFootstep::VolumeMultiplier = 1.0f

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