Spawn Blueprint C++

I think you are looking for something like this:

NOTE: You must have a base class from C++ that your blueprint children are based on for this feature.

.h File

.cpp File

For a detailed breakdown:

  • The UPROPERTY meta tags will expose the drop-down menu and accessibility from the Blueprint and will constrain valid classes to only those that derive from YourBaseClassFromC++.
  • TSubclassOf<> is the special data type that gets class values.
  • GetWorld()->SpawnActor() is the function usually used for spawning any actor.
  • The key part: SpawnableClass->GetAuthoritativeClass() will attempt to get the most-derived valid class of the SpawnableClass value passed in (i.e., will reference a Blueprint class if it was used as the value).
1 Like