Hello so I’ve been looking into loadclass or using soft class references and I’m wondering if it’s possible to use them to access a game instance (particularly by the use of TSoftClassPtr), since if I could I wouldn’t have to pass a game instance reference to methods that need to access something inside of the game instance, but the problem I’ve ran into when trying it is that I can’t access any of the members or methods of a referenced class
could any one shed some light on class pointers and if my ideas viable
The Game Instance is always created and instantiated for you by Unreal. You never have to worry about loading it yourself, so you don’t have to use LoadClass or TSoftClassPtr to access the Game Instance.
You can use the Get Game Instance global function at any time to access the current game instance, and if you’ve set it to be a custom one, you can just directly cast to it to use functions of it:
Hi I have set a game instance and it’s working, I’m just wondering if instead needing the world to access it if it would be possible to access it directly from memory by a soft class pointer or not
Since the Game Instance is a UObject you should be able to use either a direct reference or a soft pointer
I wouldn’t use a soft class pointer as that’s only for pointing to types, but it sounds like what you want is to point at the current instance.