new to programming with C++ and struggling to create a TMap with Fstring as Key and AnimMontage as value.
I’m trying to add the AnimMontage 104_montage and the error “User-defined literal operator not found” appears.
I’ve attached my cpp and .h files below.
Any help would be apprecited.
Thanks,
Mark
AnimTMap.H
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "AnimTMap.generated.h"
UCLASS()
class MYPROJECT_API AAnimTMap : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AAnimTMap();
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TMap<FString, UAnimMontage*> AnimationMap;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
AnimTMap.cpp
#include "AnimTMap.h"
// Sets default values
AAnimTMap::AAnimTMap()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AAnimTMap::BeginPlay()
{
Super::BeginPlay();
AnimationMap.Add("hello",104_montage);
}
// Called every frame
void AAnimTMap::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
You need to set your referance properly to 104_montage c++ wouldnt know if you are referencing an asset from the editor. For that purpose you need to use ConstructorHelpers::FObjectFinder
First go and copy referance from editor (since I dont have it I will go over some example.)
So when I try to access the TMap AnimationMap in a blueprint the error “FObjectFinders can’t be used outside of constructors” appears.
Fatal error: [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectGlobals.cpp] [Line: 3287] FObjectFinders can’t be used outside of constructors to find /Game/Animations/Animations/104_Montage.104_Montage