So my problem is that I thought getting an actor of class is getting the actor that I stored but it gets a random actor from this class (or not random) and problem occures when I pick up the last item on map and want to use it. It can’t find any actors and nothing happens when I use an item. Can I somehow save the reference to this item in ‘Item Info’? I tries creating an actor object reference but it didn’t work.
Thanks for the video! Actually I was not right when talking about storing.
So when I pick up an Item I destroy it and save its information with structure but I can’t get an actor if it’s destroyed I guess, however saving Item’s class is working and I thought I could call an event from class but it’s not working so I have to get an actor and then call the event. And I can’t call an actor if there’s no item left on map
Basically I want to save an Item info in structure so I can call it’s event, could you help me how to do that?
You mean like the item gives the player an ability?
Class variables will only allow you to load an asset. You can’t call a function if the object is not loaded.
Idk what that event is supposed to do, but probably it should not be in that class. Consider moving that event to the class that is spawning / calling / destroying that actor? You can “enable” that event when the actor is picked up and “disable” when called X times…
You could also spawn another actor that sole purpose is to do X, then destroy itself. It’s more or less what you are doing, but you should let that actor manage its own lifetime. For example: create a parent class with a custom destroy event, then create child classes with custom functionality that when they do what they are told to do, they call the parent event to destroy themselves. This way the struct can hold all those child classes in the same single variable for you to spawn, they’ll do X automatically and destroy themselves.
So ideally you would have an item class with child classes of different items and an ability class with several child classes with custom functionality. Item child classes could assign the player a unique pre defined ability to spawn and do stuff.
Sorry I didn’t understand what do you mean by managing it’s own lifetime
When I spawn actor I already spawn child class actor (specific Item that I need) for only this purpose as you said and then delete it