示例#1
0
        private void OnCollisionEnter(Collision collision)
        {
            damage += collision.impulse.magnitude;

            if (damage >= fallTreshold)
            {
                IsStanding = false;
                OnStandingChanged?.Invoke(IsStanding);

                if (effectRoutine != null)
                {
                    StopCoroutine(effectRoutine);
                }

                effectRoutine = StartCoroutine(EffectRoutine());
            }
        }
示例#2
0
        private IEnumerator EffectRoutine()
        {
            blender.Effector.Effect = 0f;
            yield return(new WaitForSeconds(lieDownTime));

            float t = 0f;

            while (t <= 1f)
            {
                blender.Effector.Effect = Mathf.Lerp(0f, defaultEffect, t);

                yield return(new WaitForFixedUpdate());

                t += Time.fixedDeltaTime / standUpTime;
            }

            blender.Effector.Effect = defaultEffect;
            IsStanding = true;
            OnStandingChanged?.Invoke(IsStanding);
            effectRoutine = null;
        }