I’m following a tutorial for setting up mass in my project, and I’m getting this error for a couple of my .cpp files:
0>EnemyDeathProcessor.cpp.obj: Error LNK2019 : unresolved external symbol “__declspec(dllimport) class UScriptStruct * __cdecl Z_Construct_UScriptStruct_FMassElement(enum ETypeConstructPhase)” (_imp?Z_Construct_UScriptStruct_FMassElement@@YAPEAVUScriptStruct@@W4ETypeConstructPhase@@ @Z) referenced in function “auto * __cdecl UE::StructUtils::GetAsUStruct(void)” (??$GetAsUStruct@UFMassElement@@@StructUtils@UE@@YAPEA_PXZ)
The code for the death processor, for reference:
#include "EnemyDeathProcessor.h"
#include "EnemyMassFragments.h"
#include "MassRepresentationFragments.h"
UEnemyDeathProcessor::UEnemyDeathProcessor() : EntityQuery(*this)
{
ExecutionFlags = static_cast<uint8>(EProcessorExecutionFlags::All & ~EProcessorExecutionFlags::Client);
}
void UEnemyDeathProcessor::ConfigureQueries(const TSharedRef<FMassEntityManager>& EntityManager)
{
// death processor should be able to read and write the death fragment
EntityQuery.AddRequirement<FEnemyDeathFragment>(EMassFragmentAccess::ReadWrite);
// as long as the entity is alive, its visualization will keep spawning an actor when close to the player
EntityQuery.AddRequirement<FMassRepresentationFragment>(EMassFragmentAccess::ReadOnly);
}
void UEnemyDeathProcessor::Execute(FMassEntityManager& EntityManager, FMassExecutionContext& Context)
{
EntityQuery.ForEachEntityChunk(Context,[](FMassExecutionContext& Ctx)
{
// access the fragments used
const auto Deaths = Ctx.GetMutableFragmentView<FEnemyDeathFragment>();
// because read only fragments cant be modified, have to access it as an array instead of a mutable
const auto Reps = Ctx.GetFragmentView<FMassRepresentationFragment>();
// iterate through fragment
for (int i = 0; i < Ctx.GetNumEntities(); ++i)
{
// check if entity is currently representing an actor
const bool bAlreadySpawnedActor =
Reps[i].CurrentRepresentation == EMassRepresentationType::HighResSpawnedActor ||
Reps[i].CurrentRepresentation == EMassRepresentationType::LowResSpawnedActor;
// if an already dead entity no longer represents an actor, request it be destroyed
if (!bAlreadySpawnedActor)
{
Ctx.Defer().DestroyEntity(Ctx.GetEntity(i));
continue;
}
// make entity destroy itself when specified ttl expires
Deaths[i].TTL -= Ctx.GetDeltaTimeSeconds();
if (Deaths[i].TTL <= 0.f)
{
Ctx.Defer().DestroyEntity(Ctx.GetEntity(i));
}
}
});
}
I know this error can happen when you’re missing a dependency in your build.cs file, but I’m not sure what dependency I’m missing.