I just watched the new tutorial about mass AI and I decided to code along, however at one point I get stuck, when I add the FTransformFragment, I get this error :
Severity | Code | Description | Project | File | Line | Suppression State |
---|---|---|---|---|---|---|
Error | LNK2019 | unresolved external symbol __declspec(dllimport) public: static class UScriptStruct * __cdecl FTransformFragment::StaticStruct(void) (_imp?StaticStruct@FTransformFragment@@SAPEAVUScriptStruct@@anonymous_user_9674a66c) referenced in function public: struct FMassEntityQuery & __cdecl FMassEntityQuery::AddRequirement(enum EMassFragmentAccess,enum EMassFragmentPresence) (??$AddRequirement@UFTransformFragment@@@FMassEntityQuery@@QEAAAEAU0@W4EMassFragmentAccess@@W4EMassFragmentPresence@@@Z) | LastLine | E:\unreal5\LastLine\Intermediate\ProjectFiles\SimpleMovementTrait.cpp.obj | 1 |
Here is the code :
#include "SimpleMovementTrait.h"
#include "MassEntityTemplateRegistry.h"
#include "MassCommonFragments.h"
void USimpleMovementTrait::BuildTemplate(FMassEntityTemplateBuildContext& BuildContext, UWorld& World) const
{
BuildContext.AddFragment<FMvtFragment>();
}
USimpleProcessor::USimpleProcessor()
{
bAutoRegisterWithProcessingPhases = true;
ExecutionFlags = (int32)EProcessorExecutionFlags::All;
ExecutionOrder.ExecuteBefore.Add(UE::Mass::ProcessorGroupNames::Avoidance);
}
void USimpleProcessor::ConfigureQueries()
{
EntityQuery.AddRequirement<FTransformFragment>(EMassFragmentAccess::ReadWrite);
EntityQuery.AddRequirement<FMvtFragment>(EMassFragmentAccess::ReadWrite);
}
void USimpleProcessor::Execute(UMassEntitySubsystem& EntitySubsystem, FMassExecutionContext& Context)
{
EntityQuery.ForEachEntityChunk(EntitySubsystem, Context, ([this](FMassExecutionContext& Context)
{
const TArrayView<FTransformFragment> TransformList = Context.GetMutableFragmentView <FTransformFragment>();
const TArrayView<FMvtFragment> SimpleMovementList = Context.GetMutableFragmentView <FMvtFragment>();
const float WorldDeltaTime = Context.GetDeltaTimeSeconds();
for (int32 EntityIndex = 0; EntityIndex < Context.GetNumEntities(); ++EntityIndex)
{
FTransform& Transform = TransformList[EntityIndex].GetMutableTransform();
FVector& MoveTarget = SimpleMovementList[EntityIndex].Target;
FVector CurrentLocation = Transform.GetLocation();
FVector TargetVector = MoveTarget - CurrentLocation;
if (TargetVector.Size() <= 20.f)
{
MoveTarget = FVector(FMath::RandRange(-1.f, 1.f) * 1000.f, FMath::RandRange(-1.f, 1.f) * 1000.f, CurrentLocation.Z);
}
else
{
Transform.SetLocation(CurrentLocation + TargetVector.GetSafeNormal() * 400.F * WorldDeltaTime);
}
}
}));
}
Could someone explain how to solve this?