{"id":433,"date":"2021-11-22T13:22:22","date_gmt":"2021-11-22T13:22:22","guid":{"rendered":"https:\/\/globalgoodplay.com\/?p=433"},"modified":"2022-11-07T09:59:44","modified_gmt":"2022-11-07T09:59:44","slug":"saving-and-loading-game-data-with-blueprints-and-c-in-unreal-engine","status":"publish","type":"post","link":"https:\/\/globalgoodplay.com\/?p=433","title":{"rendered":"Saving And Loading Game Data With Blueprints And C++ In Unreal Engine"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"18014\" class=\"elementor elementor-18014\">\n<section class=\"elementor-section elementor-top-section elementor-element elementor-element-719e2e4 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"719e2e4\" data-element_type=\"section\" data-settings=\"{\" jet_parallax_layout_list\":[{\"jet_parallax_layout_image\":{\"url\":\"\",\"id\":\"\"},\"_id\":\"e4af790\",\"jet_parallax_layout_image_tablet\":{\"url\":\"\",\"id\":\"\"},\"jet_parallax_layout_image_mobile\":{\"url\":\"\",\"id\":\"\"},\"jet_parallax_layout_speed\":{\"unit\":\"%\",\"size\":50,\"sizes\":[]},\"jet_parallax_layout_type\":\"scroll\",\"jet_parallax_layout_direction\":null,\"jet_parallax_layout_fx_direction\":null,\"jet_parallax_layout_z_index\":\"\",\"jet_parallax_layout_bg_x\":50,\"jet_parallax_layout_bg_x_tablet\":\"\",\"jet_parallax_layout_bg_x_mobile\":\"\",\"jet_parallax_layout_bg_y\":50,\"jet_parallax_layout_bg_y_tablet\":\"\",\"jet_parallax_layout_bg_y_mobile\":\"\",\"jet_parallax_layout_bg_size\":\"auto\",\"jet_parallax_layout_bg_size_tablet\":\"\",\"jet_parallax_layout_bg_size_mobile\":\"\",\"jet_parallax_layout_animation_prop\":\"transform\",\"jet_parallax_layout_on\":[\"desktop\",\"tablet\"]}]}\"=\"\">\n<div class=\"elementor-container elementor-column-gap-default\">\n<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-08ec16b\" data-id=\"08ec16b\" data-element_type=\"column\">\n<div class=\"elementor-widget-wrap elementor-element-populated\">\n<div class=\"elementor-element elementor-element-ab5ac01 elementor-widget elementor-widget-text-editor\" data-id=\"ab5ac01\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>No matter what type of game you are creating you will need a system that will save and load the data about the progress in your game.<\/p>\n<p>In this post we are going to take a look at how can we create save\/load system with Blueprints and C++.<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-46deb1e elementor-widget elementor-widget-heading\" data-id=\"46deb1e\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n<div class=\"elementor-widget-container\">\n<h3 class=\"elementor-heading-title elementor-size-default\">Important Information Before We Start<\/h3>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-1ea2cd7 elementor-widget elementor-widget-text-editor\" data-id=\"1ea2cd7\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>This tutorial is not for complete beginners. To follow this tutorial you will have to know your way around Unreal Engine, Blueprints and C++.<\/p>\n<p>It is not required that you are an expert in Blueprints and C++, but it is required that you know the basics, and you are comfortable creating simple games using Blueprints and C++.<\/p>\n<p>For this tutorial I am using the ThirdPerson template project, so if you want to follow along with the tutorial create a new project and select the ThirdPerson template so that you have the same set up as I.<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-3593ecf elementor-widget elementor-widget-heading\" data-id=\"3593ecf\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n<div class=\"elementor-widget-container\">\n<h3 class=\"elementor-heading-title elementor-size-default\">Modeling Game Data Blueprint<\/h3>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-8728b04 elementor-widget elementor-widget-text-editor\" data-id=\"8728b04\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<div>To demonstrate how saving and loading game data works let us create a basic example that will save and load an Integer variable.<\/div>\n<div>&nbsp;<\/div>\n<div>The first thing we need to do is create a SaveGame Blueprint. I have created a Blueprints folder in my project and this is where I am going to store my Blueprints, you will of course store yours in the appropriate folder for your game.<\/div>\n<div>&nbsp;<\/div>\n<div>To create the SaveGame Blueprint, Right Click -&gt; Blueprint Class, and in the search bar type savegame:<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-793ed4d elementor-widget elementor-widget-image\" data-id=\"793ed4d\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/1e08e2a804b05f0eb5d107f9b3c2b6f9daf22782df64518bd4f7f4f754ba532f.jpeg\" title=\"Img 1\" alt=\"Img 1\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-11b0543 elementor-widget elementor-widget-text-editor\" data-id=\"11b0543\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Give the new Blueprint name GameData. Now open GameData Blueprint in the editor, and under My Blueprint tab create a new variable type of Integer and name it score:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-756b6bd elementor-widget elementor-widget-image\" data-id=\"756b6bd\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/62ea0ea57ea7b367e3dade9c9a00951578fc446bd13eab8283e469dc7c515181.jpeg\" title=\"Img 2\" alt=\"Img 2\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-bdebcfe elementor-widget elementor-widget-heading\" data-id=\"bdebcfe\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n<div class=\"elementor-widget-container\">\n<h3 class=\"elementor-heading-title elementor-size-default\">Create A Custom Game Instance Blueprint<\/h3>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-20aa242 elementor-widget elementor-widget-text-editor\" data-id=\"20aa242\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>The one who is going to be responsible for saving and loading game data is our game instance. The reason why I am using game instance for this task is because can carry our game instance across our whole game, so no matter in which map we are in, we can use the game instance to save and load game data.<\/p>\n<p>To create a game instance Right Click -&gt; Blueprint Class, and in the search bar type game instance:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-c608230 elementor-widget elementor-widget-image\" data-id=\"c608230\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/3df6c9147eba129de233bff48def59a62231c2ac984f20709c3701c4af98c88b.jpeg\" title=\"Img 3\" alt=\"Img 3\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-81d6e67 elementor-widget elementor-widget-text-editor\" data-id=\"81d6e67\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Name the new Blueprint BP_MyGameInstance. Open BP_MyGameInstance Blueprint in the editor and in My Blueprints tab create two variables, one called Save Slot Name type of String, and the other Game Data type of GameData Blueprint that we created.<\/p>\n<p>Select the Save Slot Name variable, and in the Details tab under Default Value type GameData:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-a4e7a09 elementor-widget elementor-widget-image\" data-id=\"a4e7a09\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/db433856485e980cfc8348ba2287424920765fcfa3e2772bf046f09aa78f701d.jpeg\" title=\"Img 4\" alt=\"Img 4\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-f1f81e6 elementor-widget elementor-widget-heading\" data-id=\"f1f81e6\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n<div class=\"elementor-widget-container\">\n<h3 class=\"elementor-heading-title elementor-size-default\">Initializing Game Data<\/h3>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-7fd574b elementor-widget elementor-widget-text-editor\" data-id=\"7fd574b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>In the Event Graph tab of BP_MyGameInstance Blueprint we are going to initialize our game data. This means that when the game starts, we are going to check if the game data exists, if that is true we will load the game data, if the game data doesn\u2019t exist, that means we are running the game for the first time so we need to create a new game data.<\/p>\n<p>This is how we are going to do that:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-ccbc3f0 elementor-widget elementor-widget-image\" data-id=\"ccbc3f0\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/a624791493b3a9f924e12caa8bf2aee7d32d8c454a5738091d06d920a53df275.jpeg\" title=\"Img 5\" alt=\"Img 5\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-0c04c9e elementor-widget elementor-widget-text-editor\" data-id=\"0c04c9e\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<div>You can copy the nodes from here:<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-894413a elementor-widget elementor-widget-html\" data-id=\"894413a\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/njww7z2_\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-c8aa24b elementor-widget elementor-widget-heading\" data-id=\"c8aa24b\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n<div class=\"elementor-widget-container\">\n<h3 class=\"elementor-heading-title elementor-size-default\">Creating Functions That Will Save And Load Game Data<\/h3>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-64430b9 elementor-widget elementor-widget-text-editor\" data-id=\"64430b9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Even though this example is simple, it is always a good practice to create functions that will save and load game data, because if you don\u2019t, then you will be creating the same code in every Blueprint where you want to save game data which will lead to duplicate code and unnecessary work.<\/p>\n<p>In My Blueprint tab under functions create two functions. Name one SaveGameData and the other LoadGameData:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-38ea298 elementor-widget elementor-widget-image\" data-id=\"38ea298\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/4df1ef8e009cbfb8a10f70b9839e19add9d85caea2bd17055dbf43bc03118670.jpeg\" title=\"Img 6\" alt=\"Img 6\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-f83da7d elementor-widget elementor-widget-text-editor\" data-id=\"f83da7d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>The SaveGameData function will have a parameter of type of Integer called New Score:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-d47750d elementor-widget elementor-widget-image\" data-id=\"d47750d\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/f718af934e4ba3cc3da112da3f2008fca4ae2e8f4a029baec6e7730587c92ed3.jpeg\" title=\"Img 7\" alt=\"Img 7\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-dfc1cc3 elementor-widget elementor-widget-text-editor\" data-id=\"dfc1cc3\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>This will allow us to pass a new integer value to the function and it will save it without the need for us to get a reference to Game Data variable. Here is the Save Game Data function:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-a57ce42 elementor-widget elementor-widget-image\" data-id=\"a57ce42\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/d1844bda1730f5f987808af24ba3d813cc935603a5092dcef096a571774f7ada.jpeg\" title=\"Img 8\" alt=\"Img 8\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-ffe85bb elementor-widget elementor-widget-text-editor\" data-id=\"ffe85bb\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<div>You can copy the nodes from here:<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-96e5503 elementor-widget elementor-widget-html\" data-id=\"96e5503\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/ieukdu0o\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-a2c9c79 elementor-widget elementor-widget-text-editor\" data-id=\"a2c9c79\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<div>The LoadGameData function will have a return value of type Integer:<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-05853b1 elementor-widget elementor-widget-image\" data-id=\"05853b1\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/6f26a4c0ca8bcf2ed1b3be9004958b37aec8bc5584877fa4c66df0fc53d2026a.jpeg\" title=\"Img 9\" alt=\"Img 9\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-01125cb elementor-widget elementor-widget-text-editor\" data-id=\"01125cb\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>And this is the implementation of the LoadGameData function:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-33a8331 elementor-widget elementor-widget-image\" data-id=\"33a8331\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/f56bad8ecc1b39ed064fb39425e195d1d5ea54da781b0f1477dacde3da961bc6.jpeg\" title=\"Img 10\" alt=\"Img 10\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-b124d79 elementor-widget elementor-widget-text-editor\" data-id=\"b124d79\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<div>You can copy the nodes from here:<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-52454c2 elementor-widget elementor-widget-html\" data-id=\"52454c2\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/tt5d2z2q\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-87777c8 elementor-widget elementor-widget-heading\" data-id=\"87777c8\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n<div class=\"elementor-widget-container\">\n<h3 class=\"elementor-heading-title elementor-size-default\">Saving And Loading Game Data<\/h3>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-4239c70 elementor-widget elementor-widget-text-editor\" data-id=\"4239c70\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<div>To make this work, first we need to set our BP_MyGameInstance Blueprint to be the default game instance. To do this, we need to go in Edit -&gt; Project Settings -&gt; Maps &amp; Modes and at the very bottom you will see Game Instance option, for the Game Instance Class select our BP_MyGameInstance Blueprint:<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-5e4bffa elementor-widget elementor-widget-image\" data-id=\"5e4bffa\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/5c623432587f5b4471527b847e3fc46efb2c3bdf3dd87fc3e6f4d846a318b8e3.jpeg\" title=\"Img 11\" alt=\"Img 11\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-0f32fef elementor-widget elementor-widget-text-editor\" data-id=\"0f32fef\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>I have also created a simple UI widget that has a text that will display the game data and a button that will save the game data:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-05fad46 elementor-widget elementor-widget-image\" data-id=\"05fad46\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/02721fd28db2c1778abc2c72d4043a908b2845e404e4a2b2de058cb017eb7ebd.jpeg\" title=\"Img 12\" alt=\"Img 12\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-92fc3b7 elementor-widget elementor-widget-text-editor\" data-id=\"92fc3b7\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>In the My Blueprint tab under variables I have created a reference to the game instance type of BP_MyGameInstance:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-ca15ae8 elementor-widget elementor-widget-image\" data-id=\"ca15ae8\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/b7fe32402acdbabb64c5d22300797b660b5fb6b79d0620bdef5c1a19c21ec7d8.jpeg\" title=\"Img 13\" alt=\"Img 13\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-7ca1c9f elementor-widget elementor-widget-text-editor\" data-id=\"7ca1c9f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>And from the Event Construct node I will get a reference to the game instance:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-01dccf5 elementor-widget elementor-widget-image\" data-id=\"01dccf5\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/ce191bf85d2c62b1a4758ae0559d773e4c7d8ebba23cd477f3cbee223dd25ac6.jpeg\" title=\"Img 14\" alt=\"Img 14\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-dd9d1c9 elementor-widget elementor-widget-text-editor\" data-id=\"dd9d1c9\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>You can copy the nodes from here:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-b572155 elementor-widget elementor-widget-html\" data-id=\"b572155\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/jo3dk904\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-3b9fa6d elementor-widget elementor-widget-text-editor\" data-id=\"3b9fa6d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>I have also created a function called Set Score that is bound to the text widget which will display the score:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-92b1292 elementor-widget elementor-widget-image\" data-id=\"92b1292\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/36a9e452b5dca1aedb7221011e1091a8c00469ac15e75efeb111b0425356c611.jpeg\" title=\"Img 15\" alt=\"Img 15\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-52db8fe elementor-widget elementor-widget-text-editor\" data-id=\"52db8fe\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>You can copy the nodes from here:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-41b9136 elementor-widget elementor-widget-html\" data-id=\"41b9136\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/0m601zq3\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-cfb1a94 elementor-widget elementor-widget-text-editor\" data-id=\"cfb1a94\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>The Set Score function will call the Load Game Data function from our game instance and it will take the returned value and pass it to our text widget.<\/p>\n<p>Lastly we have the On Clicked event for our button:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-6023a18 elementor-widget elementor-widget-image\" data-id=\"6023a18\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/2133b6eaa4254981da184cb7f5c8875472ed12ccf0335e9c912c707575a0aaa9.jpeg\" title=\"Img 16\" alt=\"Img 16\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-e575524 elementor-widget elementor-widget-text-editor\" data-id=\"e575524\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>You can copy the nodes from here:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-3685d29 elementor-widget elementor-widget-html\" data-id=\"3685d29\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/1jh88d_n\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-9a0b695 elementor-widget elementor-widget-text-editor\" data-id=\"9a0b695\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Essentially when we press the button we are going to generate a random Integer from 0 to 100 and save it with the help of our game instance.<\/p>\n<p>It is not mandatory that you create the same set up, but I am using this to demonstrate how saving and loading game data works.<\/p>\n<p>Since we need to create the widget and display it in our game, I am going to create a new GameMode Blueprint, so Right Click -&gt; Blueprint Class and in the search bar type game mode:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-7e7211b elementor-widget elementor-widget-image\" data-id=\"7e7211b\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/0b743e00e0500165df260ea87f1f5f1f04b930921de7c13d5edd9f44623809bc.jpeg\" title=\"Img 17\" alt=\"Img 17\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-d7abb7d elementor-widget elementor-widget-text-editor\" data-id=\"d7abb7d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Name the new Blueprint BP_SaveLoadGameData_GameMode and inside Edit -&gt; Project Settings -&gt; Maps &amp; Modes for the default game mode set our newly created game mode Blueprint:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-f4615c2 elementor-widget elementor-widget-image\" data-id=\"f4615c2\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/da7a21ebf5d11bb943f14cd4bfc1f680544042c8a2dd4b0d486c3a1c31e396d8.jpeg\" title=\"Img 18\" alt=\"Img 18\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-e864213 elementor-widget elementor-widget-text-editor\" data-id=\"e864213\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Now we can test the game:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-1900a2f elementor-aspect-ratio-169 elementor-widget elementor-widget-video\" data-id=\"1900a2f\" data-element_type=\"widget\" data-settings=\"{\" youtube_url\":\"https:=\"\" youtu.be=\"\" ql1tdyjwpls\",\"video_type\":\"youtube\",\"controls\":\"yes\",\"aspect_ratio\":\"169\"}\"=\"\" data-widget_type=\"video.default\">\n<div class=\"elementor-widget-container\">\n<div class=\"elementor-wrapper elementor-fit-aspect-ratio elementor-open-inline\">\n<div class=\"elementor-video\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-1a48ce8 elementor-widget elementor-widget-text-editor\" data-id=\"1a48ce8\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Every time we pressed the button we generated a new random Integer that was saved, and when we stopped and run the game again that same data was loaded and displayed with the help of the text widget.<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-6aa69ba elementor-widget elementor-widget-heading\" data-id=\"6aa69ba\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n<div class=\"elementor-widget-container\">\n<h3 class=\"elementor-heading-title elementor-size-default\">Saving Player\u2019s Location<\/h3>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-8e96ebf elementor-widget elementor-widget-text-editor\" data-id=\"8e96ebf\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>The first example was a simple one that we used to demonstrate how saving and loading game data works, now we are going to save player\u2019s location inside the game and next time when we play the game we can continue from the player\u2019s last location.<\/p>\n<p>To do that, first we need to create a Vector variable inside the GameData Blueprint and name it Player Location:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-715d673 elementor-widget elementor-widget-image\" data-id=\"715d673\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/9d417ee97f7a5f3189fc299f683299452c758a1551b916aa720332e632c43061.jpeg\" title=\"Img 19\" alt=\"Img 19\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-76bece6 elementor-widget elementor-widget-text-editor\" data-id=\"76bece6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Inside the BP_MyGameInstance Blueprint I am going to create two functions, one for saving the player\u2019s location called SavePlayerLocation and one for loading player\u2019s location called LoadPlayerLocation:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-e2f2245 elementor-widget elementor-widget-image\" data-id=\"e2f2245\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/59d590366a69405c03fbd519d9220eda7987bcc8bf8011378e5b89847aa19482.jpeg\" title=\"Img 20\" alt=\"Img 20\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-e561783 elementor-widget elementor-widget-image\" data-id=\"e561783\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/00584d9e2124b4885a572045a20547b66829eac08872331e1b5760f3b42699ad.jpeg\" title=\"Img 21\" alt=\"Img 21\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-1e4d9ec elementor-widget elementor-widget-text-editor\" data-id=\"1e4d9ec\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>You can copy the nodes from here:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-1340406 elementor-widget elementor-widget-html\" data-id=\"1340406\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/9jtptfqn\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-1945df4 elementor-widget elementor-widget-html\" data-id=\"1945df4\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/g0sio1f6\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-0915479 elementor-widget elementor-widget-text-editor\" data-id=\"0915479\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<div>To save and load player\u2019s location we need to get a reference to BP_MyGameInstance, and we are going to do that inside the ThirdPersonCharacter Blueprint(I am using Third Person Project Template). First we are going to declare a variable type of BP_MyGameInstace:<\/div>\n<div>&nbsp;<\/div>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-b594ad8 elementor-widget elementor-widget-image\" data-id=\"b594ad8\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/ec6d27e9b692bd1383bb8bb9c570bf4539188f149f8a8eba2e1b044f93e1c3d1.jpeg\" title=\"Img 22\" alt=\"Img 22\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-ebb4b08 elementor-widget elementor-widget-text-editor\" data-id=\"ebb4b08\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Then, from BeginPlay we are going to get a reference to BP_MyGameInstance:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-d30b08f elementor-widget elementor-widget-image\" data-id=\"d30b08f\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/dbaba5fb1a1c006c11dbceb70cf1e21bf5015f7cc6f61c2d160ccadfc7574e09.jpeg\" title=\"Img 23\" alt=\"Img 23\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-223723c elementor-widget elementor-widget-text-editor\" data-id=\"223723c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>You can copy the nodes from here:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-9b6b166 elementor-widget elementor-widget-html\" data-id=\"9b6b166\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/8dfs24ry\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-d35c672 elementor-widget elementor-widget-text-editor\" data-id=\"d35c672\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>When we press the E button on the keyboard we are going to save the player\u2019s location, and when we press the R button we are going to load the player\u2019s location:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-2091337 elementor-widget elementor-widget-image\" data-id=\"2091337\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/glossingdress.com\/lib\/img\/all\/551\/961283330164c508c67dfb5c05d5de6575050f849a7545d27b87c01ffe249672\/3c67a1f53b388d06bcb226b2ee0deb01dc8f8d91c32ddb01245cc60f4189b026.jpeg\" title=\"Img 24\" alt=\"Img 24\"><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-59823d0 elementor-widget elementor-widget-text-editor\" data-id=\"59823d0\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>You can copy the nodes from here:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-95b28a2 elementor-widget elementor-widget-html\" data-id=\"95b28a2\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n<div class=\"elementor-widget-container\">\n\t\t\t<iframe src=\"https:\/\/blueprintue.com\/render\/mowi95xi\/\" scrolling=\"no\" allowfullscreen=\"\"><\/iframe><\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-f4e566a elementor-widget elementor-widget-text-editor\" data-id=\"f4e566a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Let\u2019s run the game and test it out:<\/p>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-c735b70 elementor-aspect-ratio-169 elementor-widget elementor-widget-video\" data-id=\"c735b70\" data-element_type=\"widget\" data-settings=\"{\" youtube_url\":\"https:=\"\" youtu.be=\"\" lo_wxz_ovfy\",\"video_type\":\"youtube\",\"controls\":\"yes\",\"aspect_ratio\":\"169\"}\"=\"\" data-widget_type=\"video.default\">\n<div class=\"elementor-widget-container\">\n<div class=\"elementor-wrapper elementor-fit-aspect-ratio elementor-open-inline\">\n<div class=\"elementor-video\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"elementor-element elementor-element-4ddd67c elementor-widget elementor-widget-text-editor\" data-id=\"4ddd67c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n<div class=\"elementor-widget-container\">\n<p>Every time we press the E key we save the player\u2019s position in the game, then no matter where we are in the level, when we press the R key, the player will be moved to the saved position. This mechanic can be a nice idea for a game<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/section>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>No matter what type of game you are creating you will need a system that will save and load the data about the progress in your game. In this post we are going to take a look at how can we create save\/load system with Blueprints and C++. Important Information Before We Start This tutorial<\/p>\n","protected":false},"author":1,"featured_media":599,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-433","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"_links":{"self":[{"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=\/wp\/v2\/posts\/433"}],"collection":[{"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=433"}],"version-history":[{"count":1,"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=\/wp\/v2\/posts\/433\/revisions"}],"predecessor-version":[{"id":600,"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=\/wp\/v2\/posts\/433\/revisions\/600"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=\/wp\/v2\/media\/599"}],"wp:attachment":[{"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/globalgoodplay.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}