Download

Question about in-game items.

Hi there,

I’ve been messing around with unreal engine 4 for past 2 weeks or so, and i started to work on a 3rd Person RPG game. currently im having a problem when it comes to ingame items.

I have an Item class which represents all attributes of an Item and its based on AStaticMeshActor class
im basing this game on a game i written in the past in python where i had a database which had all the items, and I created them ingame by creating instance of ItemClass and passing in the data from the database.

How would i create an asset of a type MyGameItem based on StaticMeshAsset which would have the attributes such as “damage, attack speed, value, item level” etc. and be able to place them within the editor into my game world?

I assume that ingame between character inventories i could just create a new MyGameItem and pass in the parameters to define the item ingame.

so far the only way to place my items into my game level within the editor is to drag the static mesh of the item into the game world, then convert the actor to MyGameItem, and then set each of its values (Name, value, icon, required level etc.). is there any way to “generate” assets based on my item class and data from file/database?

Preferably within c++

any help with this would be much appreciated, if you have any questions just ask.

I will try to answer but my English is not good.

You can do something similar to what is shown in this thread:

In the implementation I made for my project, “MyGameItem” is a blueprint that is subclass of Item.

Then I can add “MyGameItem” to a database (as shown in the thread).
You can do MyGameItem BP to spawn, by placing it directly within your level.
Or you can ask the database (by index, by name, or whatever you want) An instance of MyGameItem, which will contain the values ​​you gave him , and spawn it where you want.
In my case, I use randomized values ​​and ask to the database with these values to decide which items are spawned.

If you absolutely do not want to use anything from BP, You shoud dont have problems creating the database and adding items from c++.
You should do this every time you start the game.

You could also implement something with DataTables for Data Driven Gameplay Elements, But I still do not investigate on this.

I hope it helps

is there a way to create an Asset based on the item class without creating a blueprint for every item in the game?

i know its possible to spawn actor based on class, but is it possible to save this actor as an asset?

i dont have problems picking up items and adding them to players inventory.

i guess what im asking is how to create a place-able asset based on MyItemClass

It seems you need create another class, that you put in scene (or load if c++). In this class you need parse “ItemID” and “World position”. My advise use UEsave or xml(I use unity, that’s why xml close to me) for store necessary parameters.