Hello guys,
Since few weeks, I have been working on a save/load system for my 2 player coop game. So far, it’s working perfectly for my characters (their locations, ammos, health and so on).
However, I’m having a hard time with items that can be picked up. What I do is the following :
- A weapon is placed on the map (a child class of Blueprint Master_Pickup)
- In runtime, I save the game before picking up the weapon.
- I pick up the weapon (so the weapon is attached to my FPS character and the one on the floor is destroyed)
- I load the game a first time
- The weapon that I picked up spawn correctly at the location it was before and my character loses his weapon (so far so good !)
- The problem is that when I reload once more, the weapon does not appear (it does spawn since I make a print string on the return value of my “Spawn Actor from Class” and I get the correct name (with a different number after the name)
I think I’m doing something wrong. Here is how I did it in the Blueprint.
=> First I do a “Save game on slot” (working fine for my character blueprints) in which I store all the weapons present on the map in an array (“ItemClassArray”), as well as their location in “ItemClassTransform” array.
This array is created in the Gamemode Blueprint (the server) as you can see on Screenshot 1
=> When I load the game (screenshot 2), I get the Item Array and Transform Array from the Save slot and in the Gamemode Blueprint, what I do is that I check whether the Actor is valid. If it does exist, I just don’t spawn the weapon and apply a setactortransform so it just go back to the loaded location. If it is not valid (meaning I picked up the weapon and it has been destroyed on the floor), I spawn the class at the previous location.
The problem is that it works when I load the save once but not twice or more in a row. I don’t get why I have a return value on my “Spawn actor of class” but I cannot see the weapon on the map.
Do you guys have an idea where is the problem and if there is a better way to code this ?
I’m thanking you in advance for your help !
Sanglier Man