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

**URL:** <https://forums.unrealengine.com/t/c-enum-to-int-conversion-crashes-animation-window-when-converting/144028>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [May 20, 2020, 12:45am UTC](https://forums.unrealengine.com/t/c-enum-to-int-conversion-crashes-animation-window-when-converting/144028 "2020-05-20T00:45:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Filtiarn00](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Filtiarn00](https://forums.unrealengine.com/u/Filtiarn00)\
**Post date:** [May 20, 2020, 12:45am UTC](https://forums.unrealengine.com/t/c-enum-to-int-conversion-crashes-animation-window-when-converting/144028/1 "2020-05-20T00:45:43Z")

</div>

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.

```auto

// 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;
};

```

```auto

// 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));
}
}

```

---

<div class="post-metadata">

**Author:** ![Filtiarn00](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Filtiarn00](https://forums.unrealengine.com/u/Filtiarn00)\
**Post date:** [May 20, 2020, 12:48am UTC](https://forums.unrealengine.com/t/c-enum-to-int-conversion-crashes-animation-window-when-converting/144028/2 "2020-05-20T00:48:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Filtiarn00](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Filtiarn00](https://forums.unrealengine.com/u/Filtiarn00)\
**Post date:** [May 20, 2020, 11:19pm UTC](https://forums.unrealengine.com/t/c-enum-to-int-conversion-crashes-animation-window-when-converting/144028/3 "2020-05-20T23:19:06Z")

</div>

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?
