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

            m_GameObject            = gameObject;
            m_Transform             = transform;
            m_CharacterLocomotion   = m_GameObject.GetCachedComponent <UltimateCharacterLocomotion>();
            m_CharacterLayerManager = m_GameObject.GetCachedComponent <CharacterLayerManager>();
#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            m_NetworkInfo = m_GameObject.GetCachedComponent <INetworkInfo>();
#endif

            if (m_Feet == null)
            {
                InitializeHumanoidFeet(false);
            }

            if (m_Feet != null && m_Feet.Length != 0)
            {
                for (int i = 0; i < m_Feet.Length; ++i)
                {
                    if (m_Feet[i].Object == null)
                    {
                        continue;
                    }

                    // The FeetGrouping list should be at least the size of the current group index.
                    while (m_Feet[i].Group >= m_FeetGrouping.Count)
                    {
                        m_FeetGrouping.Add(new List <Transform>());
                    }
                    m_FeetGrouping[m_Feet[i].Group].Add(m_Feet[i].Object);
                    // The Transform should only be added to the set if the footprint is flipped. If the Transform is not in the set then the footprint is not flipped.
                    if (m_Feet[i].FlippedFootprint)
                    {
                        m_FlippedFootprints.Add(m_Feet[i].Object);
                    }
                }
            }
            else
            {
                m_FeetGrouping.Add(new List <Transform>());
                m_FeetGrouping[0].Add(m_Transform);
            }

            if (m_FootstepMode == FootstepPlacementMode.Trigger || m_FootstepMode == FootstepPlacementMode.CameraBob || m_FootstepMode == FootstepPlacementMode.None)
            {
                // The component doesn't need to be enabled if using a trigger - the FootstepTrigger component will detect the footstep. The CameraBob will enable the component
                // when the look source is attached.
                enabled = false;
            }
            else if (m_Feet != null)
            {
                PrepareVerticalOffsetLists();
            }

            EventHandler.RegisterEvent <ILookSource>(m_GameObject, "OnCharacterAttachLookSource", OnAttachLookSource);
            EventHandler.RegisterEvent <bool>(m_GameObject, "OnCharacterMoving", OnMoving);
        }
        /// <summary>
        /// Initialize the default values.
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_Transform       = transform;
            m_CapsuleCollider = GetComponent <CapsuleCollider>();
            if (m_CapsuleCollider.direction != 1)
            {
                Debug.LogError("Error: The CapsuleColliderPositioner only works with capsule colliders that are in the Y-axis direction.");
                enabled = false;
                return;
            }
            m_CharacterLocomotion   = gameObject.GetCachedParentComponent <UltimateCharacterLocomotion>();
            m_CharacterGameObject   = m_CharacterLocomotion.gameObject;
            m_CharacterTransform    = m_CharacterLocomotion.transform;
            m_CharacterLayerManager = gameObject.GetCachedParentComponent <CharacterLayerManager>();

            m_OverlapColliders = new Collider[1];

            EventHandler.RegisterEvent(m_CharacterGameObject, "OnAnimatorSnapped", AnimatorSnapped);
            EventHandler.RegisterEvent <bool>(m_CharacterGameObject, "OnCharacterImmediateTransformChange", OnImmediateTransformChange);
            EventHandler.RegisterEvent <Vector3, Vector3, GameObject>(m_CharacterGameObject, "OnDeath", OnDeath);
            EventHandler.RegisterEvent(m_CharacterGameObject, "OnRespawn", OnRespawn);

            Initialize();

#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            // The positioner cannot be used with server autoritative implementations.
            var networkInfo = m_CharacterGameObject.GetCachedComponent <Networking.INetworkInfo>();
            if (networkInfo != null && networkInfo.IsServerAuthoritative())
            {
                enabled = false;
                Debug.LogWarning("Warning: The CapsuleColliderPositioner has been disabled. Unity bug 985643 needs to be fixed for it to work over a server authoritative network.");
            }
#endif
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initialize the default values.
 /// </summary>
 private void Awake()
 {
     m_Transform             = transform;
     m_FootEffects           = GetComponentInParent <CharacterFootEffects>();
     m_CharacterLayerManager = GetComponentInParent <CharacterLayerManager>();
 }