Saving with a Pawn BP

Hello. I am learning how to make a game with a static camera that can only rotate (Something like (Darkness Within: In Pursuit of Loath Nolder). For the camera I used a pawn Blueprint, and it works fine. However, I am trying to create a save and load Blueprints, but all the tutorial out there is for a third person character or first person, and for some reason all the codes I tried did not work.

I wish to learn how to make an autosave system where the player will be back exactly where they left after exiting the game. Any ideas on how to make that happen? I appreciate any help I can get.

Thank you

You need to understand about the save game object

Basically, in your case, the player would write their location to the save game, every second or so. Then when the user runs to game again, your player knows where to start.

It’s more complicated than that, because you also need to know what doors they’ve unlocked etc, but that’s how it works.

1 Like

Sorry. It doesn’t help. It is exactly similar to all the other videos.
If I cannot change the camera, is it possible to change the material? I am using a 360 image on a screen with trigger cubes, which when double clicked, it changes the material of the sphere, making it look like The character moved. So can I save the change in materials? That would be a good start.

Thanks again.

By change I mean save the material.

Yes, you need a save game.

If the player starts in position 1 and moves to position 3 ( 2 material changes ). Next time they play, you need to start with material 3 on the screen, so they look like they’re in the same place.

The only way you can know you need to start with material 3, is by using the save game.

But what kind of variable is a material? If I try to save a player position I should choose a transform variable, right? (The Orange one). But if I am trying to save a change in the material which variable works in the save game?

I’m still a novice, but I feel like I’m transitioning into intermediate level, so bear with me :smiley:

No problemo :slight_smile:

Don’t actually try and save the material. It is possible, but it’s not a great way to do it.

What works much better, is to put your materials into an array, and just save the index to the array. Just an integer. :slight_smile:

Can you show me a bit of code where you change the material? Then I can show you how to get them in an array of the right type.


That’s how I change materials with double clicks. :slightly_smiling_face:
Also, how to use to put the material into an array and use it to save? if you have a video about it or a search term for me to look up that will be great. Thanks!

Ok, so this

image

is the critical bit. I’m assuming it’s either a material or material instance?

You need to make an array of that kind of thing. With materials, getting the right kind of variable is half the battle, to get the right kind of array do this

  1. Right click on that pin I outlined in red and choose ā€˜promote to variable’.

  2. Now just make that variable an array. Top right, details

image

  1. That’s your array. Now just put your materials in it ( compile first ):

  1. Now your code for setting the material needs to use this array, and choose the right one

  1. Now it’s easy. You just put the number you used for an index in the save game. That’s it. Next time they play, you look in the save game, you can see the int index, and just load that material from the array

:smiley:

1 Like

Hey! Sorry for the late reply, I have been busy lately. I just tried your advice.
I tried to change to an array, then this happened…

And when I compile this happens…

Did I do something wrong?

P.S. Just got your game ZoF :wink:

You have to disconnect the pin. Then pull off from the array and search for ā€˜get’ ( get a copy ), which should give you what you need.

Thanks :smiley: hope you like it! - it’s a bit of an acquired taste :slight_smile:

I saw the trailer, it’s my taste. Once I finish Heaven’s Vault I’m going down on that bad boy.

It worked. Now the only thing left is the last part. When I create a variable for the index number it (Array Index) I don’t know how to change the material number, and also how to save after that?

So to change the material, you just need the index of the material from the array, and put that in the code.

When you want to remember what index ( material ) they were on, you need the save game. This is my save game 101, which coincidentally has an example with an integer:

May I suggest something? I hope you won’t mind, but is it ok if we can have a direct chat or a zoom meeting where we can communicate better? I really don’t want to bother you, but I have been facing obstacle after obstacle and all I need is someone to help me learn Blueprints.

I can make a list and communicate with you and set a day for us to chat, if that’s alright with you?

This is fine. But message me, and we can fix something up on Discord.

You’re the best! Thank you. I’ll get back to you when I have the list ready.

Hey man. I just wanted to tell you that I finally beat your game. I was working on a horror movie which i will show in a private screening next week, in Baghdad (Yes, I’m Iraqi). Once I’m done with that, I will arrange a day for us to talk about my game.
Your game was challenging, took me a while because I am busy, and honestly, your puzzles were truly challenging. The last time my brain heated up like that was when I played ā€œSubject 13ā€.
Can’t wait to play more of your games in the future.
All the best.

Ahmed

Hey - great! :slight_smile:

I hope I can be of some help…