private void StartFireBall() { SetActivePointing(true); if (_fireBallInstance == null) { _fireBallInstance = Instantiate(_fireBallPrefab) as Fireball; _fireBallInstance.transform.SetParent(transform); _fireBallInstance.transform.position = transform.position + transform.up * -0.1f; _fireBallInstance.OnDestroyAsObservable().Subscribe(_ => { SetActivePointing(false); }); } }
void Start() { _rightArm = GameObject.FindGameObjectWithTag("RightHand").GetComponent <HandVelocity>(); _rightArm._lastVelocity.TakeUntilDestroy(this).Subscribe(velocity => { if (ShouldThrow(velocity) && _fireBallInstance != null && _canThrow) { SetActivePointing(false); _throwAudio.Play(); var direction = _throwDirection.forward; _fireBallInstance.Throw(direction, 6); _fireBallInstance = null; } }); }