I’m using UAnimInstance::AddNativeStateEntryBinding which is useful. But some times it is not working because of warning “bad machine ptr”.
I have three sub StateMachine.
- AMachine,
- BMachine,
- CMachine
I can successfully binding delegate for AMachine and BMachine and it is working fine!, but it is not working for CMachine. (actually only few anim states working and others newer working (after change name still not working!))
I debugged BindNativeDelegates and delegate is newer added to OnGraphStatesEntered.
Version UE4.8.1
Uploaded screenshoot and you can see PRIVATE_MachineDescription is null. Not sure why :\ Other StateMachines working fine.
Note: Updated to UE4.8.3 and same problem here.
Update 3
My AnimGraph design is:
RootStateMachine
|
|
AStateMachine <-------> BStateMachine
Default AStateMachine is always active but BStateMachine active when transitiun rule is true. And having problem with BStateMachine
Update 4
class UMTCharAnim : public UAnimInstance
void UMTCharAnim::NativeInitializeAnimation()
{
Super::NativeInitializeAnimation();
auto ForEachStateLambda = [&](UAnimBlueprintGeneratedClass* AnimBlueprintGeneratedClass, TFunctionRef<void(FBakedAnimationStateMachine&, const FBakedAnimationState&, int32)> Predicate)
{
for (FBakedAnimationStateMachine& StateMachine : AnimBlueprintGeneratedClass->BakedStateMachines)
{
int32 StateIndex = 0;
for (const FBakedAnimationState& State : StateMachine.States)
{
Predicate(StateMachine, State, StateIndex);
StateIndex++;
}
}
};
UAnimBlueprintGeneratedClass* AnimBlueprintGeneratedClass = Cast<UAnimBlueprintGeneratedClass>(GetClass());
if (AnimBlueprintGeneratedClass != nullptr)
{
ForEachStateLambda(AnimBlueprintGeneratedClass, [&](FBakedAnimationStateMachine& StateMachine, const FBakedAnimationState& State, int32 StateIndex) {
FString StateNameString = State.StateName.ToString();
if (IsMovementStateName(State.StateName))
{
AddNativeStateEntryBinding(StateMachine.MachineName, State.StateName, FOnGraphStateChanged::CreateUObject(this, &UMTCharAnim::OnMovementStateEntry));
AddNativeStateExitBinding(StateMachine.MachineName, State.StateName, FOnGraphStateChanged::CreateUObject(this, &UMTCharAnim::OnMovementStateExit));
}
});
}
}
Everytime compile AnimGraph you will get “bad machine ptr”
Actually I’m doing this because I have lot of states, armored, unarmored, coversystem and they have crazy transition rules so I just added to submachine for every stances. And I just relaized your roadmap for “Macro support in anim graph” Trello that will solve my problem I think.