I’m trying to spawn a cable component in c++ from the plugin to use as a rope attached to a harpoon. I tried adding the CableComponent module as a hard dependency, and that let me use ACableActor.h in my #includes, but when I start the editor, It crashes saying that I UE4Editor-CableComponent.dll is missing.
If I copy and paste the .dll from the Engine directory into my binaries, SpawnActor still can’t retrieve ACableActor’s static class. Is there an easy solution to this other than resorting to blueprints?
In HarpoonProjectile.cpp
void AHarpoonProjectile::OnActorBeginPlay()
{
UWorld* const World = GetWorld();
if (World)
{
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = Instigator;
Rope = World->SpawnActor<ACableActor>(FVector(0.f, 0.f, 0.f), FRotator(0.f, 0.f, 0.f), SpawnParams);
if (Rope)
{
}
}
}
WhaleDefence.Build.cs
using UnrealBuildTool;
public class WhaleDefence : ModuleRules
{
public WhaleDefence(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "CableComponent" });
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore", "CableComponent" });
}
}