So im trying to save and load my date and time system, the time system is on a level blueprint and the save/load system is on game inst. anyone has ideas on how i can do this? bc there seems like i cant get a variable from the level bp to the game inst or the third person char bp
Communicating with the LB is a royal pain in the neck and the very reason why scripting there is a no-no.
I mean, you can always reach the framework from anywhere:
Keep sending the current time to the Game Instance or the Character once per second - that should be precise enough? It’s 1 cast away. And the class is loaded anyway to that’s speedy. Or, since we’re LB scripting, create a direct reference to the framework, no need to cast.
so i should rather script in the third person char? also making a variable in the third person bp and getting it in the lb is better option?
Where to put it best depends how the game is structured and how data is organised.
Something like time flowing could live in the Game Mode or even Game Instance if you have multiple levels. Then anything, at any time, can access it via a cast and query.
Get Game Mode -> Cast -> Get Current Time
. Even the save game object itself can fetch it. No need to get other parties involved.
You’ve probably placed the script in the LB because the sun thingy is referenced there. You could fetch the sun with a tag from the level or dispatch its refence.
Another option:
Why not create an actor that has the sun, sky, weather (etc.) and the time-flow logic. Then you can place that actor in any level or have it dynamically spawned by any actor.
Another option:
If you prefer to keep it all as is, you can also dispatch the update to whatever other framework class you need.
- if this is the player:
- and this is the LB:
When the time is updated in the LB, the player is notified. And you already know how to access player data from the save game object.
Including what I suggested originally, now you have 4 options. Probably does make things any easier, though.
i think i will go with the new actor option bc would be much cleaner and organized and i can access it whenever i want. also can you create object refrence and material instances in the bp? for example i have a cube in the level can i then create a object ref to that cube. Thanks