Sorry from necroposting but Google’s results for “Clone Actor Blueprint” points here so the answer is more useful here.
Is true you can’t clone an actor in runtime using blueprint but isn’t too hard to create a custom blueprint who do this work:
In the editor go on File/Add C++Class and select “Blueprint Function Library” from the menu.
Rename it and click on “Create Class”
…] wait compiler and Visual Studio time
Open the file NAMEOFYOURLIBRARY.h (if you can’t find it in Visual Studio look in the Source folder of your project)
Copy this code:
class NAMEOFYOURPROJECT_API UNAMEOFYOURLIBRARY : public UBlueprintFunctionLibrary // Note: replace the project name and put a U before the name of your library
UFUNCTION(BlueprintCallable, Category = "ActorFuncions", meta = (WorldContext = WorldContextObject))
static AActor* CloneActor(AActor* InputActor);
Find and open the NAMEOFYOURLIBRARY.cpp fine (same of point 3)
Copy this code:
AActor* UNAMEOFYOURLIBRARY::CloneActor(AActor* InputActor) // Note: put a U before the name of your library
UWorld * World = InputActor->GetWorld();
UE_LOG(LogTemp, Log, TEXT("Actor Duplication"));
params.Template = InputActor;
UClass * ItemClass = InputActor->GetClass();
AActor* const SpawnedActor = World->SpawnActor<AActor>(ItemClass, params);
- Compile (from the solutions at the right, or from the compiling menu in the menu bar or MAYBE from the editor, not 100% sure)
NOTE: replace NAMEOFYOURLIBRARY with the name you give to your library in point 2, where there’s UNAMEOFYOURLIBRARY put a U in front of it. Ex: MyCPPLib -> UMyCPPLib
You can now call anywhere a node called “Clone Actor” who take in input an actor and clone it (giving you the reference to the cloned actor in output).
P.S: I’m not a C++ programmer, I only need that node and I HAD to find a way, and I wanted tho share the solution.