Пример #1
0
        private void Start()
        {
            // Listen for the animator's weapon switch event.
            RPGCharacterAnimatorEvents animatorEvents = animator.gameObject.GetComponent <RPGCharacterAnimatorEvents>();

            animatorEvents.OnWeaponSwitch.AddListener(WeaponSwitch);
        }
Пример #2
0
        private void Start()
        {
            // Get other RPG Character components.
            superCharacterController = GetComponent <SuperCharacterController>();

            // Check if Animator exists, otherwise pause script.
            animator = GetComponentInChildren <Animator>();
            if (animator == null)
            {
                Debug.LogError("ERROR: THERE IS NO ANIMATOR COMPONENT ON CHILD OF CHARACTER.");
                Debug.Break();
            }
            // Setup Collider and Rigidbody for collisions.
            capCollider = GetComponent <CapsuleCollider>();
            rb          = GetComponent <Rigidbody>();

            // Set restraints on startup if using Rigidbody.
            if (rb != null)
            {
                rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
            }
            rpgCharacterController.OnLockMovement   += LockMovement;
            rpgCharacterController.OnUnlockMovement += UnlockMovement;
            RPGCharacterAnimatorEvents animatorEvents = rpgCharacterController.GetAnimatorTarget().GetComponent <RPGCharacterAnimatorEvents>();

            animatorEvents.OnMove.AddListener(AnimatorMove);
        }