Widget + ViewModel
UEDInteractionWidget
Base widget:
UEDInteractionWidget : UUserWidget
Responsibilities:
- Store references to:
InteractionViewModelInteractableComponent
- Provide a small set of “master” functions that update the ViewModel
- Expose Blueprint events for UI animations and reactions
Key functions
SetInteractionViewModel(UEDInteractionViewModel*)SetInteractableComponent(UEDInteractableComponent*)SetInteractionPercentMaster(float Percent)UpdateUIInteractionInfoMaster(EEDInteractionMethod, const FEDWidgetInfo&)UpdateHitPointsMaster(float CurrentHitPoints, float MaxHitPoints, bool bUpdate)UpdateCooldownInfoMaster(float CooldownRemaining, float CooldownTotal, float CooldownPercent)
Key Blueprint events
PlayShowAnimationMaster()PlayDenyAnimation()OnInteractionDenied(...)OnInteractionCompleted(...)OnInteractAfterDurationStarted(...)OnInteractAfterDurationStopped(...)OnInteractionWidgetShown()OnInteractionWidgetHidden()
UEDInteractionViewModel
Base ViewModel:
UEDInteractionViewModel : UMVVMViewModelBase
It exposes:
- UI strings:
Title,Description,FocusTag - Method:
InteractionMethod - Progress:
InteractionPercent - HitPoints:
CurrentHealth,MaxHealth, derivedHealthPercent,bShowHealth - Cooldown:
Cooldown,CooldownRemaining,CooldownPercent - ButtonMashing:
ButtonMashingCountNeeded - Co-op:
MinPlayersRequired,MaxPlayersAllowed,CurrentInteractors,MultiplayerSpeedMultiplier - State:
bIsInteractionDenied
These are FieldNotify properties, so the UI can bind and update automatically.
How it is wired
When focus changes, the player component:
- Ensures a widget instance exists (choosing the interactable's requested widget class if any)
- Writes base fields into
UEDInteractionViewModel - Assigns the ViewModel and interactable component to the widget
- Plays “show” animation events and updates progress/cooldown over time