First time posting and having a lot of trouble with something that I have been deep diving for a week now. I am just trying to get my number of rounds to get displayed to my game instance or game character (would prefer the instance). It prints just fine when you go to next menu, but I cant seem to get it displayed when I call it on the character or game instance.
I have tried saving the widget to make it so it stores the variable somewhere else, but I couldn’t get that to work either. I think it is because I am removing the widget? This doesn’t make sense to me though because I am removing it and then printing the string in the picture.
The goal is to have the player pick how many rounds of golf they will do and then the game will play that many rounds. I really just need to figure out how to code it so when the player changed ones of the sliders to x, x happens in the game.
Please note: Golf ball is a Pawn not a character. Widget is User widget. Game instance is Game Instance.
The UI Widget itself should not be holding anything other than temporarily data as it does get destroyed and lost from memory when it is removed from the viewport.
The data should reside in the Game Instance or Game State class and the UI widget merely gets the data from those (this is easy because these classes are accessible by every class using the “Get Game Instance” or “Get Game State” functions).
There should be variables for each of those settings in the Game Instance/State, that the UI then can change and get.
So, take the “Ultimate Version” variable as an example…
In the Game Instance/Game State, you need to create a bool variable, along with a function to get/return that variable and a function to set that variable (You technically can just change the variable directly, but it is generally good practice to create functions to do so).
Then, in your settings UI, you can create an event “On Changed” for that checkbox and call the Game Instance/State class’ function to then set that variable to the state of the checkbox.
To get access to the Game Instance/State class, you need to call the “Get Game Instance/State” function, then cast to the specific game instance/state class that would be running in the map (otherwise the cast will fail). With that, you can then call the functions you created in the game state/instance.
Quick note, it is important to use the appropriate classes and understand why they are separated into different classes. You can read up on them here.
THANK YOU!!! You are an amazing person for explaining it so kindly and accurately to where someone with no computer science knowledge could still get it! I can not thank you enough! 20 hours of searching and all it took was for you explain that widgets don’t actually store information and walk me through the simple process!