예제 #1
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);
        }
        private void Start()
        {
            // Listen for the animator's weapon switch event.
            RPGCharacterAnimatorEvents animatorEvents = animator.gameObject.GetComponent <RPGCharacterAnimatorEvents>();

            animatorEvents.OnWeaponSwitch.AddListener(WeaponSwitch);

            // Hide all weapons when the swim action begins.
            Actions.IActionHandler swimHandler = rpgCharacterController.GetHandler("Swim");
            swimHandler.AddStartListener(HideAllWeapons);
        }