My symptom is I am never making it to the death pose. Seems the enum is not changing in the editor or from code (I verified this with UE_LOG and via this BP in the threadsafe update and using UE_Log in the Die Function. (Picture attached) But the die function is successfully getting called and the switch is working that feeds the section name into the death montage and the death animation plays, the only thing that doesn't work is the death pose.
Below is all the relevant code for what I am doing.
First here is my charactertypes.h which is indeed in the Character folder (I know this varies from the course content, I just accidentally left the S out when I made the folder). This is where I declare the enum class EDeathPose.
…UENUM(BlueprintType)
enum class EDeathPose : uint8
{
EDP_Alive UMETA(DisplayName = "Alive"),
EDP_Death1 UMETA(DisplayName = "Death1"),
EDP_Death2 UMETA(DisplayName = "Death2"),
EDP_Death3 UMETA(DisplayName = "Death3"),
EDP_Death4 UMETA(DisplayName = "Death4"),
EDP_Death5 UMETA(DisplayName = "Death5")
};```
Here are my relevant declarations in my Enemy header file.
```c++
#include "Character/CharacterTypes.h"
protected:
void Die();
UPROPERTY(BlueprintReadWrite)
EDeathPose EndingDeathPose = EDeathPose::EDP_Alive;
UPROPERTY(BlueprintReadWrite)
EDeathPose EndingDeathPose = EDeathPose::EDP_Alive;
private:
UPROPERTY(EditDefaultsOnly, Category= Montages)
UAnimMontage* DeathMontage;
…
Here is my Die and GetHit_Implimentation Functions in the Enemy.cpp
{
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
if (AnimInstance && DeathMontage)
{
AnimInstance->Montage_Play(DeathMontage);
const int32 Selection = FMath::RandRange(0,4);
FName SectionName = FName();
switch (Selection)
{
case 0:
SectionName = FName("Death1");
EndingDeathPose = EDeathPose::EDP_Death1;
break;
case 1:
SectionName = FName("Death2");
EndingDeathPose=EDeathPose::EDP_Death2;
break;
case 2:
SectionName = FName("Death3");
EndingDeathPose = EDeathPose::EDP_Death3;
break;
case 3:
SectionName = FName("Death4");
EndingDeathPose = EDeathPose::EDP_Death4;
break;
case 4:
SectionName = FName("Death5");
EndingDeathPose = EDeathPose::EDP_Death5;
break;
default:
break;
}
AnimInstance->Montage_JumpToSection(SectionName, DeathMontage);
}
}
void AEnemy::GetHit_Implementation(const FVector& ImpactPoint)
{
//DRAW_SPHERE_COLOR(ImpactPoint, FColor::Purple);
if (Attributes && Attributes->IsAlive())
{
DirectionalHitReact(ImpactPoint);
}
else
{
Die();
}
if (HitSound)
{
UGameplayStatics::PlaySoundAtLocation(
this, HitSound, ImpactPoint
);
}
if (HitParticles)
{
UGameplayStatics::SpawnEmitterAtLocation(
GetWorld(),
HitParticles,
ImpactPoint
);
}
}```
With all that being said, I feel like the real culprit could be in the editor somehow? I have been banging m head against it for some hours now though. SOS.