C++ enum to int conversion crashes Animation Window when converting

I am trying to make animation event for footstep. I using a enum for editor since it is nice for designers rather than putting in “int” directly and trying to remember which “int” is for what footstep type. I try and convert enum to int and it crashes.


// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Animation/AnimNotifies/AnimNotify.h"
#include "Sound/SoundCue.h"
#include "CoreCharacterFootstepAnimNotify.generated.h"

class UAnimSequenceBase;
class USkeletalMeshComponent;
class USoundBase;

UENUM(BlueprintType)
enum class CoreCharacterFootstepAnimNotifyType : uint8
{
Step = 0,
Crouch = 1,
Walk_Run = 2,
Sprint = 3,
Jump = 4,
Land = 5
};

ENUM_CLASS_FLAGS(CoreCharacterFootstepAnimNotifyType)

UCLASS(const, hidecategories = Object, collapsecategories, meta = (DisplayName = "Footstep"))
class PIRATEPROJECT_API UCoreCharacterFootstepAnimNotify : public UAnimNotify
{
GENERATED_BODY()

public:
UCoreCharacterFootstepAnimNotify();
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound", meta = (ExposeOnSpawn = true))
USoundCue* SoundCue;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sound", meta = (ExposeOnSpawn = true))
CoreCharacterFootstepAnimNotifyType FootstepType;
};



// Fill out your copyright notice in the Description page of Project Settings.


#include "CoreCharacterFootstepAnimNotify.h"
#include "Components/SkeletalMeshComponent.h"
#include "Components/AudioComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Sound/SoundBase.h"
#include "Animation/AnimSequenceBase.h"

#if WITH_EDITOR
#include "Logging/MessageLog.h"
#include "Misc/UObjectToken.h"
#endif

UCoreCharacterFootstepAnimNotify::UCoreCharacterFootstepAnimNotify()
: Super()
{
#if WITH_EDITORONLY_DATA
NotifyColor = FColor(196, 142, 255, 255);
#endif // WITH_EDITORONLY_DATA
}

void UCoreCharacterFootstepAnimNotify::Notify(class USkeletalMeshComponent* MeshComp, class UAnimSequenceBase* Animation)
{
if (SoundCue)
{
//Don't Play Any Looping Sounds
if (SoundCue->IsLooping())
{
UE_LOG(LogAudio, Warning, TEXT("PlaySound notify: Anim %s tried to spawn infinitely looping sound asset %s. Spawning suppressed."), *GetNameSafe(Animation), *GetNameSafe(SoundCue));
return;
}

UAudioComponent* AudioComponent = UGameplayStatics::SpawnSoundAttached(SoundCue, MeshComp);
AudioComponent->SetIntParameter(FName("FootstepType"), static_cast<int>(FootstepType));
}
}



Here is the crash.

LoginId:79dd747c4edc71a94cc6bdbfb6f232ca
EpicAccountId:8598af5547354a0e92c96a961e30ac0b

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000218

UE4Editor_Engine
UE4Editor_PirateProject_8079!UCoreCharacterFootstepAnimNotify::Notify() [C:\Users
icho\Documents\Unreal Projects\PirateProject\Source\PirateProject\CoreCharacterFootstepAnimNotify.cpp:38]
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_UnrealEd
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_UnrealEd
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Core
UE4Editor_Core
UE4Editor_Core
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Persona
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll

It seems like it is
AudioComponent->SetIntParameter(FName(“FootstepType”), static_cast<int>(FootstepType));

In Animator Window it is null but in game its not. Is there a way around this?