Hello. I’m making a spatial inventory similar to DayZ. I sketched out a small system of equipment and the inventory itself. Now I want to establish cooperation. The items being lifted are now in the form of an Actor, when they get into the inventory - the Actor is removed and I get an Object. On an item that can give its inventory (backpack, pants, jacket) there is an inventory component from where I get the data. Which I then use for interaction. Everything works until I activate the removal of the Actor after lifting the item. Because the variable I’m trying to write the component to contains only a reference, and when the Actor is deleted, the reference is invalid. If the Actor is not deleted, then everything works as intended. But I don’t want to save or move this Actor. What should I do? How can I interact with the component? Overwrite, change parameters? How can I save it, for example, in Object, so that later, when I throw the item out of the inventory, everything is preserved, or so that I can access the inventory avoiding spawn of the item?
It works
The mechanics of selection and ejection are there. I have added an inventory component to some items (jacket, backpack) so that it has additional inventory. But a component exists only when there is an actor to which it is attached. How do I save or transfer this component, or do I have to do something else?
Первое, что приходит в голову, не удалять Актора вещи, а парентить её к персонажу и прятать визуальный меш. Ведь по идее Вы таскаете её с собой. Надо подумать еще.
Второе - создать такой же BP компонент на персонаже и перенести данные.
This really isn’t a sustainable solution, but it will get the job done.
Just have an invisible actor in the world called InventoyComponentContainer or something. Then before your actor is destroyed just attach the inventory components to the Container.
Кажется я нашел путь к разгадке. Я просто сохраняю сам массив данных из инвентаря в персонаже. Если надеть эту куртку - в любом случае на персонаже создается эктор и в него я уже передаю массив, а потом вывожу результат. Единственное, пока не получится открыть контейнер внутри контейнера, но возможно это не очень реалистично и в том же Дейз для того что бы посмотреть содержимое, ты должен взять это в руки, то есть по сути также заспавнить новый эктор в руках. Так что кажется вопрос решен, осталось все это привести в нормальный вид, пофиксить баги и продолжать улучшения.