Accessed none on actor reference that is getting passed around.

esquire
Mon, 27 Jun 2016 07:04:12 +0000
Community & Industry Discussion

So I’m about to lose it.

I took some time to plan out the logic for a sort of persistent weapon stash/loadout system. I feel like this is something pretty simple, but so far my efforts have proved useless. I can spawn a weapon actor and set it as my first and second weapon, equip, fire, swap, etc with any of the weapons I have made so far, but only if I never change levels. Something about changing levels is unloading my reference or nulling it out or losing it and I can’t figure out why the game instance won’t keep it accessible.

My images are in the steps of my logic.

1. Spawn some random guns that I have functioning. They are all a child of my BP_weaponMaster class. Store them in an Array in Game Instance. (eventually this would load from a save slot, and be added to when you found a weapon.

2. In an actor I call Weapon Rack, I get the previous array, grab some items from it and pop them into another arry that has 5 indices. This is the 5 weapons in your stash I will show.

3. Use the Weapon Curator array (5 out of however many weapons you have) to spawn a new actor that will display the weapon on screen. This Weapon Display actor takes in a reference to your stash weapons.

4. I have some logic in the Weapon Display for when you hover and select it. Once its clicked it passes the reference from you stash -weaponToShow- back to the game instance and stores it in a BP_weaponMaster variable called loadOutSlot1.

5. When I spawn into the level I can press i to equip my weapons. So I can shoot, reload, swap etc.

If I open level1 and start playing, I can press i and wham, I have a gun and everything is great! If I start at my main menu, select 2 weapons from the list and then head into a level, I get accessed none on the Game Instance weapon reference.

I even tried a much simpler version where I literally just spawn 2 actors into an array and then press i to get the first index in the array. Works if I start in level1 and press i, otherwise still accessed none.

I get that when I swap levels its technically destroying those spawned actors. But even if I pass them to a setter? Re-store them in Game Instance? How would you pass a specific actor between multiple levels without having 100 exposed on spawn variables to set? Should I just store a struct with all of the stats and have the guns set their stats on load from the game instance weapon stash? Eventually I’d like to be able to create diablo style weapons that roll their stats from a CSV sheet, are persistent, etc Logic is all there for that type of deal, just don’t know how to track and keep all of them for the player.

halp!

2 posts - 2 participants