/// <summary> /// Initialize the default values. /// </summary> public override void Awake() { base.Awake(); m_CharacterIK = m_GameObject.GetCachedComponent <CharacterIKBase>(); EventHandler.RegisterEvent(m_GameObject, "OnAnimatorInteract", DoInteract); EventHandler.RegisterEvent(m_GameObject, "OnAnimatorInteractComplete", InteractComplete); }
/// <summary> /// Initializes the object. /// </summary> /// <param name="characterLocomotion">The character that is being managed by the KinematicObjectManager.</param> public void Initialize(UltimateCharacterLocomotion characterLocomotion) { m_CharacterLocomotion = characterLocomotion; OnAttachLookSource(m_CharacterLocomotion.LookSource); EventHandler.RegisterEvent <ILookSource>(m_CharacterLocomotion.gameObject, "OnCharacterAttachLookSource", OnAttachLookSource); EventHandler.RegisterEvent <bool>(m_CharacterLocomotion.gameObject, "OnCharacterChangeUpdateLocation", OnChangeUpdateLocation); // The class is pooled so reset any variables. m_HorizontalMovement = m_ForwardMovement = m_DeltaYawRotation = 0; Initialize(characterLocomotion.transform); m_CharacterHandler = m_CharacterLocomotion.GetComponent <UltimateCharacterLocomotionHandler>(); m_CharacterIK = m_CharacterLocomotion.GetComponent <CharacterIKBase>(); // Wait a moment before finishing with the initialization. This allows the character to be created at runtime. m_CompleteInitEvent = Scheduler.ScheduleFixed(Time.fixedDeltaTime / 2, () => { if (m_CharacterHandler == null) { m_CharacterHandler = m_CharacterLocomotion.GetComponent <UltimateCharacterLocomotionHandler>(); } if (m_CharacterIK == null) { m_CharacterIK = m_CharacterLocomotion.GetComponent <CharacterIKBase>(); } var smoothedBones = m_CharacterLocomotion.SmoothedBones; if (smoothedBones != null && smoothedBones.Length > 0) { var validBones = 0; for (int i = 0; i < smoothedBones.Length; ++i) { if (smoothedBones[i] != null) { validBones++; } } if (validBones > 0) { m_SmoothedBones = new SmoothFixedLocation[validBones]; var index = 0; for (int i = 0; i < smoothedBones.Length; ++i) { if (smoothedBones[i] == null) { continue; } m_SmoothedBones[index] = GenericObjectPool.Get <SmoothFixedLocation>(); m_SmoothedBones[index].Initialize(smoothedBones[i]); index++; } } } m_CompleteInitEvent = null; }); }
/// <summary> /// Initialize the default values. /// </summary> public override void Awake() { base.Awake(); m_CharacterIK = m_GameObject.GetCachedComponent <CharacterIKBase>(); #if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER m_NetworkInfo = m_GameObject.GetCachedComponent <INetworkInfo>(); #endif EventHandler.RegisterEvent(m_GameObject, "OnAnimatorInteract", DoInteract); EventHandler.RegisterEvent(m_GameObject, "OnAnimatorInteractComplete", InteractComplete); }
/// <summary> /// Initialize the perspective item. /// </summary> /// <param name="character">The character GameObject that the item is parented to.</param> /// <returns>True if the item was initialized successfully.</returns> public override bool Initialize(GameObject character) { if (!base.Initialize(character)) { return(false); } m_CharacterIK = m_Character.GetCachedComponent <CharacterIKBase>(); if (m_Object != null) { m_ObjectTransform = m_Object.transform; m_StartParentTransform = m_ObjectTransform.parent; // Represents the Items GameObject. m_StartLocalPosition = m_ObjectTransform.localPosition; m_StartLocalRotation = m_ObjectTransform.localRotation; m_ParentBone = m_StartParentTransform.parent; // Represents the bone that the item is equipped to. } // If the holster ID isn't -1 then the HolsterTarget reference will contain the Transform that the item should be attached to. if (m_HolsterTarget == null && m_HolsterID != -1) { var objectIDs = m_Character.GetComponentsInChildren <Objects.ObjectIdentifier>(); for (int i = 0; i < objectIDs.Length; ++i) { if (m_HolsterID == objectIDs[i].ID) { m_HolsterTarget = objectIDs[i].transform; break; } } } if (m_HolsterTarget != null) { // The holster target will be enabled when the item is picked up. m_HolsterTarget.gameObject.SetActive(false); } EventHandler.RegisterEvent <Vector3, Vector3, GameObject>(m_Character, "OnDeath", OnDeath); EventHandler.RegisterEvent(m_Character, "OnRespawn", OnRespawn); return(true); }
/// <summary> /// Initialize the default values. /// </summary> public override void Awake() { base.Awake(); m_CharacterIK = m_GameObject.GetCachedComponent <CharacterIKBase>(); if (m_Origin == null) { var animator = m_GameObject.GetCachedComponent <Animator>(); if (animator != null) { m_Origin = animator.GetBoneTransform(HumanBodyBones.Head); } if (m_Origin == null) { m_Origin = m_Transform; } } EventHandler.RegisterEvent <Ability, bool>(m_GameObject, "OnCharacterAbilityActive", OnAbilityActive); EventHandler.RegisterEvent <ItemAbility, bool>(m_GameObject, "OnCharacterItemAbilityActive", OnItemAbilityActive); }