How to change what actor spawns from a blueprint?
So I’m trying to setup a basic inventory system. Originally I had it so that items that were able to be acquired could be clicked on, then the actor would be destroyed and all the coding for what the item did was in my character blueprint.
I couldn’t get a functioning inventory to work well like this so I watched/read a few tutorials and changed the system. Now I have an actor named “BaseItem” that is essentially an item that can be acquired. When it is clicked on the actor is destroyed like the older method only if the player character has enough room in their inventory. I’m able to recall anything that’s picked up and the system works fine.
My only hang up is that now the only item that works with the inventory system is that BaseItem actor. So instead of duplicating that blueprint a ton and adding a bunch of stuff to my existing blueprints I thought about something: can I make the baseitem blueprint have a variable that is set to instance editable and depending on whatever the variable is the blueprint calls another actor and that is the actor that spawns?
Basically right now the only thing you can pick up in the game right now are a few guns, a flashlight, and some medkits. I was trying to use eventbeginplay in the baseitem blueprint to establish what actor is actually spawned but haven’t had any luck. Was just wondering if someone’s done something like this or if there is a way to use the baseitem actor as a vessel to spawn any one of my items.
PS - I tried setting my variable in the baseitem blueprint to an actor and use that to get that actors components so I could assign the static mesh to the mesh of baseitem but I’m going no where.
I think what you are missing from the tutorials you watched about creating a "BaseItem" (and it evens alludes to this by the name) is the parenting aspect. You can create child blueprints based off the "BaseItem" and change just about anything you like within the child. So the parent can hold common functions and variables, the children can then modify things like the mesh, the variable values and can even add unique implementation/functions not found in the parent. If you want a detailed explanation of parenting check out video #15 in the link below. Video #16 is a continuation of parenting but I take the principles discussed in the prior video and show you how to do it within Unreal Engine.
answered Jun 01 '19 at 01:50 PM
Nebula Games Inc
Follow this question
Once you sign in you will be able to subscribe for any updates here