Ensure condition failed: NULL != NewGeneratedClass when trying to use an Anim Blueprint Asset ID to set a mesh's Anim Instance Class

Hey everyone,

Issue

I can’t seem to use Set Anim Instance Class correctly using an Anim Blueprint Asset ID for an AnimBlueprint read in from a data table. I’m using C++ for the data table so I’ll include the relevant code too.

When I run my game I get this [Call Stack][1]

I’ll go from the DataTable forwards to the Blueprint code.

DataTable CSV File

1,Inara,Dreamcatcher,"""Inara is OP!""",1000,800,55,40,63,200,"""SkeletalMesh'/Game/DreamcatcherAssets/Character/ThirdPersonSkelMesh.ThirdPersonSkelMesh'""","""AnimBlueprint'/Game/DreamcatcherAssets/Character/ThirdPersonAnimBlueprint.ThirdPersonAnimBlueprint'"""

C++ Code

UtilityClass.h

USTRUCT(BlueprintType)
struct FGameCharacterLookupTable : public FTableRowBase
{
	GENERATED_USTRUCT_BODY()

public:

// UNRELATED PROPERTIES OMMITTED

	UPROPERTY()
		TAssetPtr<UAnimBlueprint> Character_Anim;

};

I then transfer the data to a CharacterProfile class

CharacterProfile.h

UCLASS(BlueprintType)
class PROJECT_DREAMCATCHER_API UCharacterProfile : public UObject
{
public:
	GENERATED_BODY()
		UCharacterProfile();

// IRRELEVANT PROPERTIES OMMITTED

	UPROPERTY( BlueprintReadOnly )
		TAssetPtr<UAnimBlueprint> characterAnim;
private:
};

UtilityClass.cpp - createDefaultCharacter() function

static FGameCharacterLookupTable* lookupRow = CharacterProfileLookupTable->FindRow<FGameCharacterLookupTable>( FName( TEXT( "1" ) ), *ContextString );

// IRRELEVANT CODE OMMITTED
newCharacter->characterAnim = lookupRow->Character_Anim;

return newCharacter;

Blueprint

Create character and set mesh from a SkeletalMesh read in from the data table

Attempt to set the Anim Instance Class for that mesh from value read in from data table

Any help would be greatly appreciated, thanks!

Oh and for anyone curious, the ReturnValue of the GetClass call on CharacterAnims created object (See the second Blueprint screenshot) is an Anim Blueprint Class

Just tried(ue 4.10.2) something like this but with structs instead of data tables. i can’t get it working with BP, while in code it works just fine. Looks like a bug!

p.s. i mean dynamic changing not working, if you just wire set anim instance class and selected a class from list it works…

Ah yes that’s right, mine worked too if I selected it from the usual list.

If this is a bug I think I’ve shot myself in the foot here. I don’t think I can move this to the bug section. So I either need to hope a mod sees this and moves it for me, or I create a new question in the bug section and let them know it’s a copy of this.

Edit: Found it, I’ve moved it into the bug section, will see what others say

Hello Punitiate,

Thank you for making this report. I tried setting up my own reproduction of this in 4.10.2 but I haven’t run into any ensure calls. Does this only happen if you’re using structs or data tables? Is it only when you’re using a mix of C++ and Blueprints or does it never work in blueprints regardless?

Hey Matthew,

I’ve got some free time tomorrow night so I’ll take a look at trying to reproduce with a fresh, simplified project and get some answers to your questions.

A quick question as I’m trying to setup a fresh project to reproduce this in so that if I’m successful I can send to you.

    //.hpp
	UPROPERTY( BlueprintReadOnly )
		TAssetPtr<USkeletalMesh> characterMesh;
	UPROPERTY( BlueprintReadOnly )
		TAssetPtr<UAnimBlueprint> characterAnim;

//.cpp

	characterMesh = nullptr;
	characterAnim = nullptr;

Compiled fine in my old project, doesn’t compile in my new one. Both the same version of Unreal. The compilation errors I get are:

1>D:\Program Files\Epic Games\4.9\Engine\Source\Runtime\CoreUObject\Public\UObject\AssetPtr.h(123): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'const UAnimBlueprint *' (or there is no acceptable conversion)
1>          d:\program files\epic games\4.9\engine\source\runtime\coreuobject\public\uobject\PersistentObjectPtr.h(46): could be 'void TPersistentObjectPtr<FStringAssetReference>::operator =(const TObjectID &)'
1>          with
1>          [
1>              TObjectID=FStringAssetReference
1>          ]
1>          d:\program files\epic games\4.9\engine\source\runtime\coreuobject\public\uobject\PersistentObjectPtr.h(57): or       'void TPersistentObjectPtr<FStringAssetReference>::operator =(const UObject *)'
1>          d:\program files\epic games\4.9\engine\source\runtime\coreuobject\public\uobject\PersistentObjectPtr.h(75): or       'void TPersistentObjectPtr<FStringAssetReference>::operator =(const FWeakObjectPtr &)'

Same for mesh.

I tried reproducing this using Blueprint datatables only but couldn’t even load in the DataTable elements for the mesh and animation. They just appeared as NULL.

Either way I’m suspecting I’m not using TAssetPtr correctly in my old project as I don’t think I’m explicitly loading the resource.

I believe your last comment is correct. While TAssetPtr’s are pointers, I’m not even sure that they can be set to null in the same way. I haven’t used them in a while so I’m a bit rusty but I do remember this wiki page being very helpful in learning how to use them.

It turns out I wasn’t using TAssetPtr’s correctly. I had another read of the documentation Matthew provided and I made a bad assumption that TAssetPtr would automatically load the asset the first time that it was referenced.

Instead you have to load it somewhere else or via TAssetPtr.LoadSynchronous().

The animation still doesn’t apply but I consider that a separate problem with my code.

I no longer get the condition failure so I’m happy to end it here.