예제 #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);
        }