Best Way To Make (1) Template Item For Many Unique Items In Game?
I am curious on best way of creating a (1) template item to be picked up in a game, but this item would have many unique meshes and settings? So I could easily drop this template item many times in the level, but then change its mesh and settings so it could be a total different item, but with the same core functionality to be picked up.
Would I use enumerations? Even though their may be 100's of items or is there another way that may be more preferred?
asked Jul 03 '14 at 02:48 AM in Blueprint Scripting
You're talking about Blueprint Inheritance: https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/Blueprints_Advanced/2_5/
Here's the gist of it.
Create a blueprint called BP_Pickup or BP_Item or something generic like that. Put all your item functionality inside that, like inventory handling, score, whatever. Make the generic values like "Score" or "Gold Cost" or "Weight" public variables while you're in there. Give it a blank static mesh component.
Now create a new blueprint that's called like BP_Sword or something. In it's class settings set it's parent class to BP_Item:
After you've done that, hit compile. Now set the static mesh component to your sword mesh. In the Class Settings you'll have variables for Score, Gold Cost, Weight, etc that you made in BP_Item.
Do the same for BP_TreasureBag, BP_Pistol, BP_Mushroom and the rest of your items. If you need specific behavior for an item (like BP_Mushroom changes psychedelic colors until it's picked up) you can put that in the specific item, otherwise put all generic behavior in BP_Item.
As you master Blueprint Inheritance, you might make children like BP_ShortSword, BP_LaserSword, BP_WoodenSword that all have their own custom behaviors and are all children of BP_Sword (which has the common sword code in it) which is a child of BP_Item (which has the common item code in it).
answered Oct 11 '17 at 01:40 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here