Download

A bloody newbie doesn't know how to work... GameInstance?

Hi everyone…
I’m coming from a 3D Design studio and we normally work with Cinema 4D.
Now my boss said, I have to learn Unreal Engine to show architectural visualisation in VR.

I have soooo many question but start with that one:
I had to do something similar in Unity with Playmaker (an State Machine Scripting, kind of like Blueprint) once and there I had the possibility to store global values. I already have read that this should be possible with the GameInstance Blueprint. But I can’t get it to work and I don’t know why. Honestly I don’t know exactly what to do and I’m searching for all kinds of tutorials and so on.

The goal for the first step I wanted to take was switching levels (got that one) and the next one is to keep the position of the camera(?) or player(?) or whatever the Player_Start is.
I tried to use the Architechtural Preset (the one room with the red sofa) where there is a Daylight and a Nightlight Level.
I used a trigger to switch level, I also tried it with a keyboard assign, that worked too. But it always spawns back to the player start, obviously.
Can anyone help me? ^^

Greetings :slight_smile:

Game instance is great to store variables. I make all my global variables in there. That’s about all I’m using mine for. Not much actual ‘blueprint’ scripting in it. Just a list of variables.

Then you castto >yourgameinstance (with object -game instance) to get the variables during game.

I do have this custom event in my game instance (that’s all I have there). It is used to save all the variables that are in my SaveGame class bp.

At a certain point in my levels I call the save game event and it stores all these for next reload. (I just use a trigger box)
Game instance is good because you can call it globally from any BP. But you need all those variables in SaveGame bp to save them between games.

You can get your camera location (get world transform, etc…) in the player_BP with the camera and just send the varible to game instance.


Then when the next map loads I call the save game

Thanks for your help! I know have another problem I encountered just now. I made some BP Changes to the Blueprint of the Player_Start. I get the location and store it in a vraible in the GameInstance BP. But the problem is when I get the location or the transform of the BP_Player_Start I get the same value no matter wherer I go to trigger the saving of the variables. I placed a cube into the Player_Start_BP and saw, that the Player Start isn’t moving so it doesn’t change its position. But what actually changes it’s position in this level then?

I use the Project “RealisticRendering”, that you can create for free.

https://forums.unrealengine.com/core/image/gif;base64
​Is this during the same game session or are you quiting and restarting?

Game Instance will only save the variables during runtime.

You need a save game BP to save between games.

In the pics above My game save event is inside my game instance. (triggered in game by button or overlap trigger box, etc…)
The ‘get’ references are variables in the game instance bp. (car selection, paintjob…)
The Set references are variables in the save game bp.
So I’m using the game instance to count stuff during runtime. When the ssave game is triggered I save all the variables I want by transfering those numbers to the save game.

The second pic is in my map. On load it calls the sve game, checks the numbers and sets them in my game instance. Then the game can change them… then save again later.

Hi,

this is during Runtime. When I press the play button in the upper bar.
But the problem is, as I guess, not the storing itself, it stores the transformation data of the “Player_Start”. But this particular object isn’t moving, what means that I always get the same value to store. The problem for me is to figure out, what actor/object is really moving so that I can store my variable from that actor and not the one, that isn’t moving at all.

But thank you very much until now, helped me understand that whole system a lot :slight_smile: