Saving weapons between levels

When I equip a weapon and approach a teleportation point to another level, the player itself is teleported, but the weapon is not. If I take the weapon and save it, it will be saved with me, but even then, the weapon is destroyed when I transition to the other level. Please help me, I don’t know what to do.

You will have to re-execute the weapon actor initialisation again once the level has been loaded.

How do I do that? I’ve been using this save system as a basis

Hey @AngFallen!

If the information about the weapon is being saved, you need to run a function to spawn your weapon and attach it to your player. I’d put it in as part of Begin Play and make sure the info is there with an isValid? check before running it (so if you don’t have a weapon, you don’t get a null reference exception).

There’s not really much we can do with that video as if you’re just using it as a base level, we don’t know the intricacies of your personal project. :frowning: But you can get us some pics or even video, right? :slight_smile:

If you’re opening a new level you’d have to save the equipped weapon in a saved game file, then re equip it on begin play. An alternate would be to implement level streaming. This would be a smoother approach in my opinion.

thanks you so much :grinning_face:

I figured out what the problem was, my system wasn’t designed to save between levels, and I did everything as NN suggested. I found similar videos, and my conclusion is that the system isn’t suitable for this. I already know how to make a new one, so I’ll try to implement it.

1 Like

I still haven’t been able to solve my problem, please help me

you cant save Object References (the blue nodes) you have to recreate them.

So for example your SaveWeapon, you have to save its data (class, ammo etc) and respawn it, reattach it and reload it.

Saving/Loading is a big task if you’re not prepared

And how do I do that?

it depends on your data, Id need to know what you SaveWeapon is, if for instance its created from a DataTable then all you need to do is save the Row and rebuild it, you may need a struct for any modular data such as ammo.

if its built from a class then save the class and rebuild it the same way.

in short you need to save all Actors/Objects the same way you save your Character

SaveGame is made as a function in MayGameInstanc, and the save itself works at the level and saves weapons and armor, etc., but when I switch, everything resets

your health and transform should at least work? otherwise you may have a logic/order of operations problem.

loading within the same level may ‘seem’ to work because your weapon/armor object exists in the world but when you change levels they cease to exist.