Skip to main content

Widget + ViewModel

UEDInteractionWidget

Base widget:

  • UEDInteractionWidget : UUserWidget

Responsibilities:

  • Store references to:
    • InteractionViewModel
    • InteractableComponent
  • 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, derived HealthPercent, 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:

  1. Ensures a widget instance exists (choosing the interactable's requested widget class if any)
  2. Writes base fields into UEDInteractionViewModel
  3. Assigns the ViewModel and interactable component to the widget
  4. Plays “show” animation events and updates progress/cooldown over time