Hello. How can i make an assignment on changes of a variable so that will run logic if it’s changed?
Quick solutions that come to my mind, either:
- Create a setter method that will set the variable’s value and fire the logic you want afterwards. For consistency, you’ll have to use this method everywhere you want to change a value. Creating Setters/Getters is a common practice in programming overall, and if you are using C++, there is even a property specifier that you can use instead:
UPROPERTY(BlueprintSetter="abc")- All UPROPERTY Specifiers · ben🌱ui - Make the variable replicated and use OnRep_ functionality. This will make this variable weight a little bit more, and you’ll have to make the owning actor replicated, but this works exacly how you wanted in the first place. For more info about OnRep, check this page: 1.4 - Variable Replication [RepNotify] | Unreal Engine 4.27 Documentation
1 Like