Esempio n. 1
0
        /// <summary>
        /// Initialize the defualt values.
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_TrailRenderer = GetComponent <TrailRenderer>();
            if (m_TrailRenderer != null)
            {
                m_TrailRenderer.enabled = false;
            }
            m_ParticleSystem = GetComponent <ParticleSystem>();
            if (m_ParticleSystem != null)
            {
                m_ParticleSystem.Stop();
            }

            // The Rigidbody is only used to notify Unity that the object isn't static. The Rigidbody doesn't control any movement.
            var destructableRigidbody = GetComponent <Rigidbody>();

            if (destructableRigidbody != null)
            {
                destructableRigidbody.mass        = m_Mass;
                destructableRigidbody.isKinematic = true;
                destructableRigidbody.constraints = RigidbodyConstraints.FreezeAll;
            }
#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            m_NetworkInfo         = GetComponent <INetworkInfo>();
            m_DestructibleMonitor = GetComponent <IDestructibleMonitor>();
#endif

            if (m_DestroyOnCollision && m_CollisionMode != CollisionMode.Collide && GetType() != typeof(MagicProjectile))
            {
                Debug.LogWarning($"Warning: The Destructible {name} will be destroyed on collision but does not have a Collision Mode set to Collide.");
                m_CollisionMode = CollisionMode.Collide;
            }
        }
        /// <summary>
        /// Initialize the defualt values.
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_TrailRenderer = GetComponent <TrailRenderer>();
            if (m_TrailRenderer != null)
            {
                m_TrailRenderer.enabled = false;
            }
            m_ParticleSystem = GetComponent <ParticleSystem>();
            if (m_ParticleSystem != null)
            {
                m_ParticleSystem.Stop();
            }

            // The Rigidbody is only used to notify Unity that the object isn't static. The Rigidbody doesn't control any movement.
            var rigidbody = GetComponent <Rigidbody>();

            rigidbody.mass        = m_Mass;
            rigidbody.isKinematic = true;
            rigidbody.constraints = RigidbodyConstraints.FreezeAll;
#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            m_NetworkInfo         = GetComponent <INetworkInfo>();
            m_DestructibleMonitor = GetComponent <IDestructibleMonitor>();
#endif

            if (m_DestroyOnCollision && m_BounceMode != BounceMode.None)
            {
                Debug.LogWarning("Warning: The Destructible " + name + " will be destroyed on collision but does not have a Bounce Mode set to None.");
                m_BounceMode = BounceMode.None;
            }
        }