Where should I put my UI code in?

Say, I have a Character class can be possessed by both AI and human player.

I have some C++ code to spawn and modify UI widget for some scenarios like changing weapon icon when weapon changed, setting up the crosshair for different weapons. Of course, when a character possessed by AI doing something like this, I don’t want to run the UI-related code.

What’s the proper way to separate the UI code from the character? Do I need to create custom PlayerController or something? How to determine if a character is controlled by AI or player properly?

Hello! I just use (non-UClass) simple c++ class with static delegates, that that are used to bind Player actions and inputs to UI things. Most simple implementation can look like this UE4Cookery CPP002: Static delegate trick

That’s a helpful post, thank you.