I have two classes (AActor and UUserWidget), I have an Actor Object instance in the Widget class, and when I pickup that actor in game, I change a boolean value from false to true. The Widget class checks every tick if the bool is true or not, and if it is true then it runs a function.
The problem is, that the bool value NEVER updates in the Widget class, it does change in the Actor class, but it stays false in the Widget class.
You’re destroying the instance of the actor in which you’re setting the bool.
You’re creating another instance in the widget.
These are two separate instances.
You don’t really need to?..
You’re only creating and instance in the widget when you pick up an actor, right?
Set a variable in the newly created instance, not in the one that’s being picked up and destroyed.
Thats correct. But what I have to do is to somehow run a function in widget class after I picked up the actor. This is why I made a bool to change its state after I picked up the actor.
You need some kind of communication between classes. You can do it through the character or the controller, depending which class creates the widget.
For instance, when you pick up the actor, call a custom function in the widget with the actor class as an argument.
Now it works, and now I know that probably the gamemode, controller, character and maybe a few more classes run always at runtime, so they get updated, later I will reorganize stuff and put them into functions to make it run cleaner and look cleaner!