Beispiel #1
0
    protected override void ActivatorWakeUp()
    {
        base.ActivatorWakeUp();

        if (mRespawnReady)
        {
            SetPhysicsActive(true, true);

            //Debug.Log("respawned");
            mRespawnReady = false;
            state         = (int)EntityState.Normal;
        }
        else
        {
            if (!respawnOnSleep && animator && animator.onDisableAction == AnimatorData.DisableAction.Pause)
            {
                animator.Resume();
            }
        }
    }
Beispiel #2
0
    void SetPhysicsActive(bool aActive, bool excludeCollision)
    {
        if (rigidbody)
        {
            if (!mSpawnRigidBodyKinematic)
            {
                rigidbody.isKinematic = !aActive;
            }

            if (aActive || !excludeCollision)
            {
                rigidbody.detectCollisions = aActive;
            }
        }

        if (collider && (aActive || !excludeCollision))
        {
            collider.enabled = aActive;
        }

        if (mGravCtrl)
        {
            mGravCtrl.enabled = aActive;
        }

        if (animator)
        {
            if (aActive)
            {
                if (animator.isPaused)
                {
                    animator.Resume();
                }
            }
            else
            {
                if (animator.isPlaying)
                {
                    animator.Pause();
                }
            }
        }

        if (mBodyCtrl)
        {
            mBodyCtrl.enabled = aActive;
        }

        for (int i = 0, max = mDamageTriggers.Length; i < max; i++)
        {
            mDamageTriggers[i].gameObject.SetActive(aActive);
        }
    }