void Start() { // Set HpBar external references and reparent. hpBar.selTrans = sel.trans; hpBar.height = hpBar.transform.position.y; hpBar.transform.SetParent(wolrdUiTrans); // Update HP bar and detect death. CurrentHp .TakeUntilDestroy(gameObject) .ThrottleFrame(0, FrameCountType.EndOfFrame) .Subscribe(hp => { hpBar.SetProgress(hp / maxHp); if (hp <= 0) { this.Die(); } }); }