Download

Spawn Blueprint at runtime from code using path of blueprint.

So i asked on AnswerHub but never got a reply so am going at it again here. :slight_smile:

Am wondering if i have a class e.g: AWeapon:: derived from AActor::.
In the class i have Skeletal Mesh component for the weapon, Audio components for the Weapon Sounds and so on.
And the logic on how and when its played and displayed is all defined in the class.

I then make a Blueprint of that class that is a “real weapon”, with all its propertys filled in e.g: Mesh, Sounds, so 4th.
To get a blueprint class for the pawn in my Game Mode class i do the following.


static ConstructorHelpers::FObjectFinder<T> MemberName(TEXT("Blueprint`Path/Path/BP_Asset.BP_Asset`"));
if (PlayerPawnObject.Object != NULL)
{
	DefaultPawnClass = (UClass*)PlayerPawnObject.Object->GeneratedClass;
}

How can i do this at runtime ? As far as i know found out, i can not use this outside the contructor of a class.

?] I want to know how can i take the path of a blueprint and spawn that Blueprint class with only the path string at runtime/ In-Game?

Am i wrong, or is there a way?
Thanks in advanced.

https://answers.unrealengine.com/questions/59674/how-to-spawn-actor-from-string-path-to-actor-bluep.html

I believe I solved that issue :wink:

Thank you so much :).
Seeing the snip i am thinking to my self i need to know more about the UObject::.
Cheers!