I’m creating a game in Third Person Mode. I’m trying to add vehicles to the game but I have a problem when I switch to the car possession.
In my ThirdPersonCharacter I have a component called “InventoryPlayer”, that stores all data of the Inventory of the player (weapons, ammo, consumables, etc.).
The process is:
Player in game spawns, pickup weapons, etc. and then enter a vehicle. When he enter to a vehicle, character is unpossessed and destroyed. Then I possess the car and move with the car. When I exit the car I Spawn an actor near the car to simulate he drives to the location he want.
The problem is when I destroy the actor, all inventory is destroyed and when I create the character it creates like a new character. It’s obiously. I want to know if there’s an option to store the entire character bp and then when I spawn the actor, spawn it with the previously saved character or if there’s another option to make this possible.
you could add the inventory component to the car as well or somewhere to store the inventory.
when unpossessing the pawn you need to set “store the inventory” somewhere other then the character so you could retrieve it later when you possess a new pawn.
you could store variables in game instance temporarily if your game is single player mode.
you have to screenshot something so I could help you further.
When I created my inventory I ran into the same problem. The solution is to not create the inventory on the player but somewhere else and your player just has access to it. I setup my inventory in the game mode since I can just get game mode in my player and cast to my game mode to grab and store it in a variable. If you do this then when your player is destroyed the inventory still exists and upon spawning your character just make sure that it is set in the player to On begin play get the inventory from the game mode and store it in a variable.
What these guys said is best way. Have an empty blueprint actor in the scene which stores inventory. What you could also do is not destroy the pawn when unpossessed but just hide it from view and disable its collisions. Then reposses the same pawn after exiting the vehicle (teleport the inventory pawn near the car first)
I’m trying to store the Inventory on PlayerController. Another thing I’ll try is to not possess the car, just AttachToActor and change the input to the car input or something.