示例#1
0
        /// <summary>
        /// Initialize the default values.
        /// </summary>
        public override void Awake()
        {
            base.Awake();

            m_Handler = m_GameObject.GetCachedComponent <UltimateCharacterLocomotionHandler>();

            // Work with the handler to listen for any input events.
            if (m_Handler != null)
            {
                m_StartRotateInputEvent = ObjectPool.Get <ActiveInputEvent>();
                m_StartRotateInputEvent.Initialize(ActiveInputEvent.Type.ButtonDown, m_RotateInputName, "OnRPGMovementTypeStartRotate");

                m_StopRotateInputEvent = ObjectPool.Get <ActiveInputEvent>();
                m_StopRotateInputEvent.Initialize(ActiveInputEvent.Type.ButtonUp, m_RotateInputName, "OnRPGMovementTypeStopRotate");

                m_TurnInputEvent = ObjectPool.Get <ActiveInputEvent>();
                m_TurnInputEvent.Initialize(ActiveInputEvent.Type.Axis, m_TurnInputName, "OnRPGMovementTypeTurn");

                m_AutoMoveInputEvent = ObjectPool.Get <ActiveInputEvent>();
                m_AutoMoveInputEvent.Initialize(ActiveInputEvent.Type.ButtonDown, m_AutoMoveInputName, "OnRPGMovementTypeAutoMove");

                m_Handler.RegisterInputEvent(m_StartRotateInputEvent);
                m_Handler.RegisterInputEvent(m_TurnInputEvent);
                m_Handler.RegisterInputEvent(m_AutoMoveInputEvent);
            }
            EventHandler.RegisterEvent(m_GameObject, "OnRPGMovementTypeStartRotate", OnStartRotate);
            EventHandler.RegisterEvent(m_GameObject, "OnRPGMovementTypeStopRotate", OnStopRotate);
            EventHandler.RegisterEvent <float>(m_GameObject, "OnRPGMovementTypeTurn", OnTurn);
            EventHandler.RegisterEvent(m_GameObject, "OnRPGMovementTypeAutoMove", OnToggleAutoMove);
        }
示例#2
0
        /// <summary>
        /// Initialize the default values.
        /// </summary>
        public override void Awake()
        {
            base.Awake();

            m_Handler = m_GameObject.GetCachedComponent <UltimateCharacterLocomotionHandler>();

            EventHandler.RegisterEvent <bool>(m_GameObject, "OnCharacterGrounded", OnGrounded);
            EventHandler.RegisterEvent(m_GameObject, "OnAnimatorJump", ApplyJumpForce);
        }
示例#3
0
            /// <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;
                });
            }
示例#4
0
    // Use this for initialization
    void Start()
    {
        unityInput        = GetComponent <UnityInput>();
        locomotionHandler = GetComponent <UltimateCharacterLocomotionHandler>();
        locomotion        = GetComponent <UltimateCharacterLocomotion>();
        characterIk       = GetComponent <CharacterIK>();

        animator = GetComponent <Animator>();
        runtimeAnimationController = animator.runtimeAnimatorController;

        UpdateAvatar();

        SetUmaReady(false);
    }
示例#5
0
        /// <summary>
        /// Initialize the default values.
        /// </summary>
        public override void Awake()
        {
            base.Awake();

            m_Handler = m_GameObject.GetCachedComponent <UltimateCharacterLocomotionHandler>();
            if (m_Collider != null)
            {
                if (!(m_Collider is CapsuleCollider) && !(m_Collider is SphereCollider))
                {
                    Debug.LogError("Error: Only Capsule and Sphere Colliders are supported by the Lean ability.");
                    m_Collider = null;
                    return;
                }

                m_OverlapColliders   = new Collider[m_MaxCollisionCount];
                m_ColliderGameObject = m_Collider.gameObject;
                m_ColliderTransform  = m_Collider.transform;
                m_ColliderGameObject.SetActive(false);
            }
            EventHandler.RegisterEvent <bool>(m_GameObject, "OnCharacterChangePerspectives", OnChangePerspectives);
        }