How can I spawn a BP Actor using code?
Basically, I have an inventory system where what I have set up is that I have coded the base class for an item (that can be picked up and put into the inventory, which is a TArray) in C++, and have created blueprints based off of it (because it is easier to just drag on the static mesh I want, rather than hard code it in.), and basically when the player wants to drop an item, it raycasts out and finds an the first hitpoint with the ground, and then spawns the actor there. Here is the spawn code:
(Hit being an FHitResult).
The actor is being spawned, but because its a BP, all the previous information associated with it, (the mesh, other variables, etc) aren't given to it (by default the item is basically nothing), and I was curious if I was able to get the class of the blueprint, from which is stored into the inventory array, and spawn it with all its previous information.
Thankyou in advance.
Well, WCode solved this one for me (again), basically what I did was adapt https://answers.unrealengine.com/questions/53689/spawn-blueprint-from-c.html into a more dynamic system. Basically, on the item blueprint, you have to set a variable (UBlueprint*) to itself, and when the object needs to be recreated, it just uses
answered Jun 14 '14 at 01:05 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here