Spawning blueprint actor from C++ fails
I made a projectile class, which is basically for now the same thing as the projectile in the twin stick shooter demo project. I then made a blueprint that derived from it. I'd like to be able to spawn this blueprint but every time I try to do a SpawnActor it returns NULL. In the header of the file I'm trying to do this in, I have declared:
class UBlueprint* HeavyProjectileActor;
In the constructor for it, I have:
And in the part where I'm trying to spawn the actor I do this:
(SpawnLocation and FireRotation are set up above it). The projectile is never added and the return result from SpawnActor is NULL.
My guess is I screwed up how I'm trying to get the blueprint reference. Please note that when I break at that line and view the contents of HeavyProjectileActor it's not NULL and appears to be populated with valid data.
asked Jan 23 '15 at 10:06 AM in C++ Programming
OK after some sleep I figured it out. For one, I needed to declare the variable as a UClass* not a UBlueprint*. I then changed line 12 in the previous code block I pasted to:
Note that it's just appending ->GeneratedClass to what used to be there.
Then for spawning, I just simply pass in HeavyProjectileActor rather than HeavyProjectileActor->GetClass().
answered Jan 23 '15 at 07:42 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here