After compiling the Animation Blueprint (ABP) during Play In Editor (PIE), the callback registered with UAnimInstance::AddNativeStateEntryBinding() in NativeInitializeAnimation() stops functioning as expected. Specifically, the callback is called expectedly before the compilation, but after recompiling the ABP during the PIE session, the callback is no longer triggered.
Workaround: Restart PIE whenever ABP is compiled.
Expected Result: "Log OnEnteredAnyAnimationState Walk / Run -> Idle" appears in the log when you move the character and stop it. It means the callback should continue to function correctly after recompiling the ABP during PIE.
Actual Result: That log is not output to log anymore. The callback stops functioning (= not being called) after the ABP is recompiled during PIE.
Code Snipet: (* The repro project is available and attached)
MyAnimInstance.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Animation/AnimInstance.h" #include "MyAnimInstance.generated.h" /** * */ UCLASS() class TPCPP54_ISSUE_API UMyAnimInstance : public UAnimInstance { GENERATED_BODY() public: void NativeInitializeAnimation() override; void OnEnterAnyAnimationState(const struct FAnimNode_StateMachine& machine, int32 prevStateIndex, int32 nextStateIndex); };
MyAnimInstance.cpp
#include "MyAnimInstance.h" #include <Animation/AnimNode_StateMachine.h> void UMyAnimInstance::NativeInitializeAnimation() { Super::NativeInitializeAnimation(); UE_LOG(LogTemp, Log, TEXT("Log NativeInitializeAnimation Owner:%s"), *GetNameSafe(GetOwningActor())); AddNativeStateEntryBinding(TEXT("Locomotion"), TEXT("Idle"), FOnGraphStateChanged::CreateUObject(this, &ThisClass::OnEnterAnyAnimationState)); } void UMyAnimInstance::OnEnterAnyAnimationState(const struct FAnimNode_StateMachine& machine, int32 prevStateIndex, int32 nextStateIndex) { UE_LOG(LogTemp, Log, TEXT("Log OnEnteredAnyAnimationState %s -> %s"), *machine.GetStateInfo(prevStateIndex).StateName.ToString(), *machine.GetStateInfo(nextStateIndex).StateName.ToString()); }
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-221858 in the post.
0 |
Component | UE - Anim - Runtime - Anim Blueprints |
---|---|
Affects Versions | 5.4.3 |
Target Fix | 5.6 |
Created | Aug 15, 2024 |
---|---|
Updated | Sep 26, 2024 |