Starfield Backdrop Only


To better simulate the AED scenario, we model the player’s BPM (compressions per minute) so they can learn and keep a safe, consistent chest-compression cadence.
Goal
Continuously estimate the player’s compression rate (BPM) over a short window and trigger feedback when the cadence is too slow.
Key variables
  • PressCount: number of compressions recorded in the current window.
  • TotalTime: accumulated sampling time (seconds) for the current window.
  • UpdateFrequency: how often we sample/update the estimate (seconds).
  • KeyFrequency (BPM): computed BPM value (PressCount / TotalTime × 60).
Data Flow (left → right)
CalculateFrequency (Custom Event)
This event is called on a loop (e.g., by a Timeline or Timer) at UpdateFrequency seconds.
Accumulate time and inputs
  • TotalTime ← TotalTime + UpdateFrequency.
  • PressCount is updated (from the latest input aggregator) and stored.
Compute BPM
  • KeyFrequency ← (PressCount / TotalTime) × 60.
    The ×60 converts “presses per second” into “presses per minute”.
Minimum window guard
  • Branch checks: TotalTime > 5.0.
    We only start judging cadence after at least 5 seconds of data to avoid noisy early estimates.
Threshold check and feedback
  • Branch compares: KeyFrequency < 90.0.
    If True, call OnPlayerBPMTooLow (e.g., UI hint, audio metronome, controller rumble).
    If False, no penalty is issued (you can add “good pace” feedback if desired).
Animation trigger (contextual)
  • Play Animation on the Skeletal Mesh Component can fire when a valid press is registered, reinforcing the feel of each compression while the BPM logic runs in the background.
Outcome
The system turns raw button presses into a stable BPM estimate, waits for a reliable sample window, and then warns the player when they’re too slow—helping them learn and maintain proper AED compression cadence.