コード例 #1
0
        private void Awake()
        {
            rpgCharacterMovementController = GetComponent <RPGCharacterMovementController>();
            rpgCharacterWeaponController   = GetComponent <RPGCharacterWeaponController>();
            rpgCharacterInputController    = GetComponent <RPGCharacterInputController>();
            animator = GetComponentInChildren <Animator>();
            if (animator == null)
            {
                Debug.LogError("ERROR: There is no animator for character.");
                Destroy(this);
            }
            //Find HeadLookController if applied.
            headLookController = GetComponent <PerfectLookAt>();
            ikHands            = GetComponent <IKHands>();
            //Set for starting Relax state.
            weapon = Weapon.RELAX;
            animator.SetInteger("Weapon", -1);
            animator.SetInteger("WeaponSwitch", -1);
            StartCoroutine(_ResetIdleTimer());
            //Turn off headlook in editor.
#if UNITY_EDITOR
            headLook = false;
#endif
            isHeadlook = headLook;
        }
コード例 #2
0
 private void Awake()
 {
     //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 <RPGCharacterAnimatorEvents>();
         animator.GetComponent <RPGCharacterAnimatorEvents>().rpgCharacterController = this;
     }
     rpgCharacterMovementController = GetComponent <RPGCharacterMovementController>();
     rpgCharacterWeaponController   = GetComponent <RPGCharacterWeaponController>();
     rpgCharacterInputController    = GetComponent <RPGCharacterInputController>();
     //Find HeadLookController if applied.
     headLookController = GetComponent <PerfectLookAt>();
     ikHands            = GetComponent <IKHands>();
     //Set for starting Unarmed state.
     weapon = Weapon.UNARMED;
     animator.SetInteger("Weapon", 0);
     animator.SetInteger("WeaponSwitch", -1);
     StartCoroutine(_ResetIdleTimer());
     //Turn off headlook in editor.
                 #if UNITY_EDITOR
     headLook = false;
                 #endif
     isHeadlook = headLook;
 }
コード例 #3
0
 void Awake()
 {
     rpgCharacterMovementController = GetComponent <RPGCharacterMovementController>();
     rpgCharacterInputController    = GetComponent <RPGCharacterInputController>();
     animator = GetComponentInChildren <Animator>();
     if (animator == null)
     {
         Debug.LogError("ERROR: There is no animator for character.");
         Destroy(this);
     }
     if (target == null)
     {
         Debug.LogError("ERROR: There is no target for character.");
         Destroy(this);
     }
 }
コード例 #4
0
 void Awake()
 {
     superCharacterController    = GetComponent <SuperCharacterController>();
     rpgCharacterController      = GetComponent <RPGCharacterControllerFREE>();
     rpgCharacterInputController = GetComponent <RPGCharacterInputController>();
     navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>();
     animator     = GetComponentInChildren <Animator>();
     rb           = GetComponent <Rigidbody>();
     if (rb != null)
     {
         //Set restraints on startup if using Rigidbody.
         rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
     }
     //Set currentState to idle on startup.
     currentState      = RPGCharacterState.Idle;
     rpgCharacterState = RPGCharacterState.Idle;
 }
コード例 #5
0
 private void Awake()
 {
     //superCharacterController = GetComponent<SuperCharacterController>();
     rpgCharacterController      = GetComponent <RPGCharacterController>();
     rpgCharacterInputController = GetComponent <RPGCharacterInputController>();
     animator    = GetComponentInChildren <Animator>();
     capCollider = GetComponent <CapsuleCollider>();
     rb          = GetComponent <Rigidbody>();
     if (rb != null)
     {
         //Set restraints on startup if using Rigidbody.
         rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;
     }
     //Set currentState to idle on startup.
     currentState      = RPGCharacterState.Idle;
     rpgCharacterState = RPGCharacterState.Idle;
 }
コード例 #6
0
        private void Swimming()
        {
            if (rpgCharacterController.isSwimming)
            {
                float swimTime = 0.5f;

                if (GUI.Button(new Rect(25, 175, 100, 30), "Swim Up"))
                {
                    swimTimeout = Time.time + swimTime;
                    jumpInput   = Vector3.up;

                    // Override the jump input for a half second to simulate a button press
                    RPGCharacterInputController inputController = rpgCharacterController.GetComponent <RPGCharacterInputController>();
                    if (inputController != null)
                    {
                        inputController.PauseInput(swimTime);
                    }
                }
                if (GUI.Button(new Rect(25, 225, 100, 30), "Swim Down"))
                {
                    swimTimeout = Time.time + swimTime;
                    jumpInput   = Vector3.down;

                    // Override the jump input for a half second to simulate a button press
                    RPGCharacterInputController inputController = rpgCharacterController.GetComponent <RPGCharacterInputController>();
                    if (inputController != null)
                    {
                        inputController.PauseInput(swimTime);
                    }
                }
                if (Time.time < swimTimeout)
                {
                    rpgCharacterController.SetJumpInput(jumpInput);
                }
            }
        }