Wow, thank you. Been building my game for a year as a total beginner. Only ever had one level until last week, but was a bit lost as to how to progess. Just got something to save between levels and am feeling elated! Subscribed.
@commandingsteel Жыл бұрын
Thank you Sir!...took me a little bit to integrate it into my project, but now I'm well under way into having a functional game instead of just a level cheers
@I-MM-O-R-T-A-L Жыл бұрын
did i ever told you how much i love you? You are helping so much, great work, great explanations.... continue as you do!
@sebastianosorioarango6270 Жыл бұрын
I dont understand the minute 19:00, i have to create a custom event in the GI or in the ThirdPersonCharacter BP?
@emptybruh Жыл бұрын
If you are going the custom event rount, you make the event inside tpcharacter, attach everything you want to that event than cast to tpcharacter bp inside instance and run said event on Event Init
@chasesommer Жыл бұрын
If the variables are not showing up at 10:00, try setting Health and Stamina as text instead of integers. That's working for me now in 5.2. I'm sure there's a better way and would love some feedback!
@IrocZIV2 жыл бұрын
I like that you explained the why, and showed some issues that you might experience. It is a bit long, feels like it would have been a good livestream, and then a more concise video could be made from it after you worked out the bugs in the presentation. Thanks for the video.
@GDXR2 жыл бұрын
If this was a live stream it would have been much longer lol.
@jazzypizzle9 ай бұрын
Super understandable and well explained. Thank you sir!
@stoneageprogrammer432 Жыл бұрын
Hey this is a cool video and I've subbed you. I've been studying GameInstance lately, but I'm still very new to GameDev and Unreal. I'm making a game with multiple levels, and discovered that the gun that I found in one level does not transfer into the next level. So I discovered GameInstance, but I still don't know how to code that. I got a note from another dev who described the logic. Here is what he wrote: "Gameinstance is like this. 1. You create a Gameinstance. 2. You set in Project Setting to use your Gameinstance. 3.Before you switch a level you save all what you want keep to the Gameinstance. 4. After you switched the level. You call the Gameinstance and load all the things which you saved in the Gameinstance back to the new level. I don't know how you make an inventory System but I think they use data tables. Lets make an example with your gun. Lets say step 1 and 2 you did. Step 3 is : Save the gun mesh in your GameInstance as a gun mesh variable. 4. You are switching the level. In the new level you need set your gun mesh. So you call your Gameinstance, find the saved gun mesh and use this saved gun mesh to set the gun mesh in the new level. Now your new level has the gun from before. I am not sure if this is the best way but as a start point it should work." Like I said, I don't know how to turn that into Blueprints. Do you think you might do another tutorial demonstrating this procedure?
@StormFrontGame Жыл бұрын
thankyou, this has helped alot!!
@katiekaliber Жыл бұрын
Oke i was good with everything until you started doing the initialize in the instance and then told us to call it in our player blueprint while doing something different yourself, i can't for the life of me figure out what you mean by that because i can't call upon that custom event from my player if made in the instance. Could you explain what you meant?
@TheD3vilHimself2 жыл бұрын
Bro, Nice Shirt! I see you are a man of class and style.
@jimmypi20352 жыл бұрын
Great tut, thank You. May I ask, what if we store some values/variables in actors and pawns that are dynamically spawned as the game progress? How to cast to those objects even if they are not in the scene yet :| :??? hlp
@TheJesusjones2 жыл бұрын
Amazing video Jonathan - very well explained and demonstrated!
@Pierraxl11 ай бұрын
Why don't you just plug the "As game instance " from the cast directly into the Set integer ? Instead of creating a variabale et get it again right after ? thanks
@amitbeharier5698 Жыл бұрын
Amazing. Thank you!
@sams_3d_stuff2 жыл бұрын
Hey! Love your videos!
@GDXR2 жыл бұрын
Glad you like them!, Thank you.
@CronicGaming94 Жыл бұрын
I'm only having an issue with one item. Which is the first person rifle component. Everything else seems to transfer fine but the rifle does not. Any idea how to fix this? The bHasRifleVariable is still stored when i changed levels but the rifle itself is gone.
@thehotpotatosquad Жыл бұрын
You need to store the rifle as actor object reference, or enum from where you chose the actor to spawn.
@FDOF_Dev Жыл бұрын
Question... why not just reference your game instance at begin play and then get that reference, and pull off of it and setting the desired variables directly as they change? And then you could use those variables from the game instance directly for your binds in your widget, right?
@FDOF_Dev Жыл бұрын
Oh thanks BTW. The part about how event dispatchers and how using an object reference in the game instance instead of checking from each chest, solid advice. Well explained.
@GDXR Жыл бұрын
So this isnt a bad way of thinking about it however it can cause issues. For example if your game instance loads first and you then your setting variables it can cause other things refrencing it to pull null values because they havent been set yet. For example UI. Is your player spawns and has a ui set on begin play. the UI can comunicate to the game instance. But if the player spawns, cast to the game instance and then sets a variable. It's possible your UI has already spawned before the game instance sets the variable. So if the UI is trying to access something that hasnt been set yet. It will break. You need to consider the load order of things.
@FDOF_Dev Жыл бұрын
@@GDXR oh okay. Cool. Thanks for the heads up.
@katiekaliber Жыл бұрын
@@GDXR Thank you, that makes a lot of sense.
@LDT7Y Жыл бұрын
How big should the game instance file ideally be at maximum (for a data heavy rpg, specifically)? I'm a bit concerned (perhaps unneccessarily) that my game instance is already about 20mb and I haven't even added most of the 400+ quests to it yet.
@FlockersDesign10 ай бұрын
Its funny when he says his is just from the top of my head When he reads the documentation from Unreal them self about GameInstance😂😂
@GDXR10 ай бұрын
The examples are off the top of my head.
@DimitryArsenev Жыл бұрын
I need more when 1 Game Instance. I cant make all logic in one class. How its can be fixed?
@GDXR Жыл бұрын
you can only have one game instance, you will need to implement a character possessions system and look into the Player Controller Class
@DimitryArsenev Жыл бұрын
@@GDXR No thanks. Example - i make logic for sql database - its not Player logic. Now i just use static classes - i init it in game instance class. Also i think possible make many Game Instances - its subcomponents logic, but i not try it.
@ionthedev Жыл бұрын
@@DimitryArsenev unless you customize the engine, you can't have more than one game instance, as each time a packaged application made in in unreal is ran, the game instance is created on the opening of the application and is destroyed on closing the application. That is just how unreal works For your use case, which I've done something similar with Mongo, is to just write the data directly to the database instead of storing it in the game instance directly.
@DimitryArsenev Жыл бұрын
@@ionthedev I just use UGameInstanceSubsystem, its way to have unlimited game instances.
@gordon7936 Жыл бұрын
Is casting to game instance good idea If I need to have variables that i might change every frame? I'm told casting is not great for performance, so what's better way to keep global variable, even per level, not the whole game?
@GDXR Жыл бұрын
So the game instance is where you will want to keep global variables, however these can also be stored in Structs to stop the game instance having to much to manage. For the casting, casting to the game instance isnt bad, it always exhists so the game instance cast will never fail. however seting variables inside the game instance on tick/ever frame is a bad idea, You should only send information when you really need to and its unlikely that the game instance needs to know this amount of data.
@gordon7936 Жыл бұрын
@@GDXR Thank you for your answer. For what I know I still have to keep the struct as a variable in some place. I hoped there's some way to have a global variable, like the material parameter collection, that I can easily access anywhere, but I see that's not possible with pure blueprints.
@jaybenny54772 жыл бұрын
hi im a student and preparing for a competition about vr development(make a scene that has interacitve functions,character,animation,level designs ) ,sametime, has a UI platform . The subject is about learning English,also my idea is to grab the letters from one box to combine a word on a screen as a beginner idk how long it would cost (i must finish it in 1 mouth) and is there any courses help me study this ?
@mch438562 жыл бұрын
really helpful thank you!
@rossedwards57242 жыл бұрын
A very clerar tutorial, thank you
@GDXR2 жыл бұрын
Glad it was helpful!
@OpenMawProductions Жыл бұрын
So, if you're making something like a first person shooter, you would have to save: Player health, player armor, player inventory, current weapons that have been picked up, current ammo for each weapon, current ammo in each weapons magazine (if they have that)... All in the game instance? Doesn't this start to get a little... Insane? Or am I just not understanding this correctly.
@GDXR Жыл бұрын
No, your correct. You add all the variables you plan to save inside your game instance is it's a persistant actor (Not destroyed between levels). Then inside the game instance you have a create save game object. Which you then pass the variables through to. But yes, with blueprints, this get's, Insane.
@ogradus2 жыл бұрын
I could be wrong, but isn't the PlayerController also persistent also?
@GDXR2 жыл бұрын
Player controllers are persistant between levels but in most cases are only used when your dealing with multiple players/characters/possesion. The game instance is normaly used by devs doing single player content.
@ogradus2 жыл бұрын
@@GDXR that is a relief! There are so many tools and it's hard to know what is good for certain things. It makes more sense to use a game instance, but I suppose I can make this work. I'm making an RTS and I've been wondering if I can save all the stats/locations of selected units by using object references, which I've stored in the player controller. I'll let you know how it goes. Thank you for your response!
@KavanBahrami2 жыл бұрын
25:10 reminding you to link the event dispatcher video in the description ;)
@GDXR2 жыл бұрын
Thank you.
@chas38182 жыл бұрын
Thanks for the vid, got it working with my health which is great. How does this work with Actor Variables? For context I have a sword blueprint being saved as an actor variable thats being attached to my player, and I followed the same sort of set up as the health where it calls the event dispatcher to update when you pick up a sword but no luck, returns is not valid so the variable isnt loading on begin play
@rubenminasyan98012 жыл бұрын
thanks so much
@thereanimator60722 жыл бұрын
Great video! My player has 18 variables I need to store between levels. Do I need to create a custom event for each variable or can I use a sequence perhaps? Thank you
@GDXR2 жыл бұрын
If you have multiple variables, all 18 should be stored in your game instance. From there you can create a system so the actor on begin play casts to the game instance (Same code as the thumbnail) and then sets the variable you need. Your actor should only grab the variable they need.
@lz40902 жыл бұрын
Very helpful. Could you also do a game mode tutorial? Thank you
@ROSALIEIK Жыл бұрын
dont get it
@GDXR Жыл бұрын
If you have a variable that needs to be stored between level loading. Then you need a game instance to store the values. Let's say your player has been damaged and there health is currently 32%. If you load a new level there health value will reset to default 100%. So storing the health inside the game instance means, when you load the next level. There health will stay at 32% and won't be reset.