Cannot call the function LineBatcher->DrawMesh


I wanted to draw a debug polygon. Since there was no DrawDebug function to draw a polygon or a triangle, I dug a bit deeper into the debug codes and found out about LineBatchComponent that is called by the DrawDebugHelper


void DrawDebugLine(const UWorld* InWorld, FVector const& LineStart, FVector const& LineEnd, FColor const& Color, bool bPersistentLines, float LifeTime, uint8 DepthPriority, float Thickness)
	// no debug line drawing on dedicated server
	if (GEngine->GetNetMode(InWorld) != NM_DedicatedServer)
		// this means foreground lines can't be persistent 
		ULineBatchComponent* const LineBatcher = GetDebugLineBatcher( InWorld, bPersistentLines, LifeTime, (DepthPriority == SDPG_Foreground) );
		if(LineBatcher != NULL)
			float const LineLifeTime = (LifeTime > 0.f) ? LifeTime : LineBatcher->DefaultLifeTime;
			LineBatcher->DrawLine(LineStart, LineEnd, Color, DepthPriority, Thickness, LineLifeTime);

And the LineBatchComponent has a DrawMeshFunction which I decided to call on a custom plugin

ULineBatchComponent* const LineBatcher = GetWorld()->ForegroundLineBatcher;
LineBatcher->DrawMesh(TransformedVerts, Indices, FColor::Green, 1, DeltaTime);

I get a linker error when doing the compilcation

Module.FighterPlugin.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl ULineBatchComponent::DrawMesh(class TArray<struct FVector,class FDefaultAllocator> const &,class TArray<int,class FDefaultAllocator> const &,struct FColor const &,unsigned char,float)" (?DrawMesh@ULineBatchComponent@@QEAAXAEBV?$TArray@UFVector@@VFDefaultAllocator@@@@AEBV?$TArray@HVFDefaultAllocator@@@@AEBUFColor@@EM@Z) referenced in function "protected: virtual void __cdecl UFlipBookDebugComponent::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)" (?TickComponent@UFlipBookDebugComponent@@MEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z)

Any way I can call the code directly?

I’ve actually gotten this working myself for my game, all you need to do is add the correct module under PublicDependencyModulNames in your plugin’s build.cs file. The module you’re looking for is “Engine” iirc.