private void Awake()
 {
     rpgCharacterMovementController = GetComponent <RPGCharacterMovementControllerFREE>();
     rpgCharacterWeaponController   = GetComponent <RPGCharacterWeaponControllerFREE>();
     rpgCharacterInputController    = GetComponent <RPGCharacterInputControllerFREE>();
     //Setup Animator, add AnimationEvents script.
     animator = GetComponentInChildren <Animator>();
     if (animator == null)
     {
         Debug.LogError("ERROR: There is no Animator component for character.");
         Destroy(this);
     }
     else
     {
         animator.gameObject.AddComponent <RPGCharacterAnimatorEventsFREE>();
         animator.GetComponent <RPGCharacterAnimatorEventsFREE>().rpgCharacterController = this;
         animator.gameObject.AddComponent <AnimatorParentMoveFREE>();
         animator.GetComponent <AnimatorParentMoveFREE>().anim = animator;
         animator.GetComponent <AnimatorParentMoveFREE>().rpgCharacterMovementController = rpgCharacterMovementController;
     }
     ikHands = GetComponent <IKHandsFREE>();
     //Set for starting Unarmed state.
     weapon = Weapon.UNARMED;
     animator.SetInteger("Weapon", 0);
     animator.SetInteger("WeaponSwitch", -1);
     StartCoroutine(_ResetIdleTimer());
 }
Exemplo n.º 2
0
        private void Start()
        {
            rpgCharacterController         = GetComponent <RPGCharacterControllerFREE>();
            rpgCharacterMovementController = GetComponent <RPGCharacterMovementControllerFREE>();
            rpgCharacterWeaponController   = GetComponent <RPGCharacterWeaponControllerFREE>();

            //Check if Animator exists, otherwise pause script.
            if (rpgCharacterController.animator == null)
            {
                Destroy(this);
                return;
            }
        }
Exemplo n.º 3
0
        private void Awake()
        {
            //Initialize other RPG scripts.
            rpgCharacterMovementControllerFREE = GetComponent <RPGCharacterMovementControllerFREE>();
            rpgCharacterWeaponControllerFREE   = GetComponent <RPGCharacterWeaponControllerFREE>();
            rpgCharacterInputControllerFREE    = gameObject.AddComponent <RPGCharacterInputControllerFREE>();

            //Setup Animator, add AnimationEvents script.
            animator = GetComponentInChildren <Animator>();
            if (animator == null)
            {
                Debug.LogError("ERROR: THERE IS NO ANIMATOR COMPONENT ON CHILD OF CHARACTER.");
                Time.timeScale = 0f;
                Destroy(this);
                return;
            }
            else if (!animator.isHuman)
            {
                Debug.LogError("ERROR: CHARACTER AVATAR RIG IS NOT HUMANOID.");
                Time.timeScale = 0f;
                Destroy(this);
                return;
            }
            else
            {
                animator.gameObject.AddComponent <RPGCharacterAnimatorEventsFREE>();
                animator.GetComponent <RPGCharacterAnimatorEventsFREE>().rpgCharacterController = this;
                animator.gameObject.AddComponent <AnimatorParentMoveFREE>();
                animator.GetComponent <AnimatorParentMoveFREE>().anim = animator;
                animator.GetComponent <AnimatorParentMoveFREE>().rpgCharacterMovementController = rpgCharacterMovementControllerFREE;
                animator.updateMode  = AnimatorUpdateMode.AnimatePhysics;
                animator.cullingMode = AnimatorCullingMode.CullUpdateTransforms;
            }

            ikHandsFREE = GetComponentInChildren <IKHandsFREE>();

            //Set for starting Unarmed state.
            weapon = Weapon.UNARMED;
            animator.SetInteger("Weapon", 0);
            animator.SetInteger("WeaponSwitch", -1);
            StartCoroutine(_ResetIdleTimer());
        }
 private void Awake()
 {
     rpgCharacterController         = GetComponent <RPGCharacterControllerFREE>();
     rpgCharacterMovementController = GetComponent <RPGCharacterMovementControllerFREE>();
     rpgCharacterWeaponController   = GetComponent <RPGCharacterWeaponControllerFREE>();
 }