In my project there are some functions I would like to implement that will be useful in the vast majority of my Blueprint scripts, im still quite new to visual scripting and am having trouble trying to work out the best way to implement some form of global functions for lack of a better word to describe it.
I thought a function library would be what I needed but they do not support variables of their own for an unknown reason to me so that took that out.
My next solution was to create a “Utility” blueprint that held all of my functions and just create a variable to hold a reference to this blueprint that I can set inside whatever blueprint I wanted to use the functions in, but this just raised a more troubling question of what would the best base class for this “Utility” blueprint be?
If anyone can shed some light on a best practices for this type of thing as I dont want to have to create local functions with the same functionality in every blueprint script I want to use them in.
Thank you, if there is anything that needs clarifying please ask.
Best way to store map-wide data is either custom GameMode (for server-only stuff) or GameState (for all clients also). You can choose what GameMode to use in “World Settings” tab. In its turn, GameMode allows you to specify what GameState to use.
My implementation, of what your speaking of, was to add an additional blueprint, and honestly? the class just doesnt’ matter.
Why?
Who cares… The Blueprint is nothing more than a repository of data and functions, using structs, etc. making it easier and less overlap among all the other blueprints that use it So long as all the blueprints htat need those functions/data, know how to find that blueprint, it can be anywhere, doing anything that is needed. The way I did it, was that at begin event processing, all the client blueprints look for the “server/repository” blueprint, the server does the, same, hence they don’t even care about execution order. For if the “server/repository” is called before it init’s via the begin processing, it simply calls a function internaly that Begin Event will call, that “init” function checks if it’s ever been called, and if i’ts called more than once, it simply returns. In this fashion,everyone is ready for anything at any time. and I don’t have to mess around in the Game setup with this, Allowing me to play in my own little sandbox, and do what ever I wish, without worrying about, if I do something in product provided by Epic Games, will I break something at some future date? Will they change something that breaks my code, etc.
In truth, once I put this together, I found a ton of things it was good for.