How can I make a callable function for a C++ class without initiation?
I am trying to create an AInventoryItem that will have a virtual function its children will call and override. The end goal is that each item made for the game will have its own unique UseItem() function but it can be called without creating an instance. I understand that functions can be made static, which makes them callable without an instance, but static functions cannot be virtual.
I am trying to avoid spawning an item to use its function, turning off collision and visibility, and then destroying it when its effect is complete. I know UE4 automatically deletes objects that go so far out of range. I want to avoid littering the game with a ton of invisible items and I don't want anything to be auto-deleted before completion (Say an elixir that lasts for an hour).
Does anyone know a simple way to reconcile this issue?
Thanks in advance.
asked Dec 08 '16 at 03:22 PM in C++ Programming
I think encapsulating the item in a struct or UObject is the way to go. Have everything that needs to be available at "inventory time" be available. Only spawn the item when you really need it.
That is how I implement my inventory stuff most of the time.
answered Dec 08 '16 at 03:56 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here