示例#1
0
        void OnTriggerExit(Collider _collider)
        {
            Rigidbody body = _collider.attachedRigidbody;

            if (body != null)
            {
                m_rigidbodies.Remove(body);

                GravityHistory history = m_histories[body];
                if (history.currentZone == this)
                {
                    history.currentZone = history.lastZone;
                    history.lastZone    = null;
                }

                if (history.lastZone == this)
                {
                    history.lastZone = null;
                }

                if (history.currentZone == null)
                {
                    body.useGravity = true;

                    PlayerController player = _collider.GetComponent <PlayerController>();
                    if (player != null)
                    {
                        player.SetUpDirection(-Physics.gravity.normalized);
                    }
                }
            }
        }
示例#2
0
        void OnTriggerEnter(Collider _collider)
        {
            Rigidbody body = _collider.attachedRigidbody;

            if (body != null)
            {
                body.useGravity = false;
                m_rigidbodies.Add(body);

                GravityHistory history = null;
                if (!m_histories.TryGetValue(body, out history))
                {
                    history = new GravityHistory();
                    m_histories.Add(body, history);
                }

                if (history.currentZone != this)
                {
                    history.lastZone    = history.currentZone;
                    history.currentZone = this;
                }

                PlayerController player = _collider.GetComponent <PlayerController>();
                if (player != null)
                {
                    player.SetUpDirection(-m_gravity.normalized);
                }
            }
        }