void OnSceneGUI()
    {
        if (Selection.activeGameObject != null && PrefabUtility.GetPrefabType(Selection.activeGameObject) == PrefabType.Prefab || !Selection.activeGameObject.activeSelf)
        {
            return;
        }
        meleeEquip = (vMeleeManager)target;

        var coll = meleeEquip.gameObject.GetComponent <Collider>();

        if (coll != null && meleeEquip != null && meleeEquip.hitProperties != null && meleeEquip.hitProperties.useRecoil && meleeEquip.hitProperties.drawRecoilGizmos)
        {
            Handles.DrawWireDisc(coll.bounds.center, Vector3.up, 0.5f);
            Handles.color = new Color(1, 0, 0, 0.2f);
            Handles.DrawSolidArc((Vector3)coll.bounds.center, Vector3.up, meleeEquip.transform.forward, (float)meleeEquip.hitProperties.recoilRange, 0.5f);
            Handles.DrawSolidArc((Vector3)coll.bounds.center, Vector3.up, meleeEquip.transform.forward, (float)-meleeEquip.hitProperties.recoilRange, 0.5f);
        }
    }
        public override void Init()
        {
            base.Init();

            fwd         = transform.forward;
            destination = transform.position;
            agent       = GetComponent <UnityEngine.AI.NavMeshAgent>();

            agentPath    = new UnityEngine.AI.NavMeshPath();
            sphereSensor = GetComponentInChildren <v_AISphereSensor>();
            if (sphereSensor)
            {
                sphereSensor.root = transform;
            }
            meleeManager = GetComponent <vMeleeManager>();
            canAttack    = true;
            attackCount  = 0;
            sideMovement = GetRandonSide();
            destination  = transform.position;

            _rigidbody             = GetComponent <Rigidbody>();
            _rigidbody.useGravity  = true;
            _rigidbody.constraints = RigidbodyConstraints.None | RigidbodyConstraints.FreezeRotation;
            agent.updatePosition   = false;
            agent.updateRotation   = false;
            agent.enabled          = false;
            _capsuleCollider       = GetComponent <CapsuleCollider>();

            // avoid collision detection with inside colliders
            Collider[] AllColliders = this.GetComponentsInChildren <Collider>();
            Collider   thisCollider = GetComponent <Collider>();

            for (int i = 0; i < AllColliders.Length; i++)
            {
                Physics.IgnoreCollision(thisCollider, AllColliders[i]);
            }

            healthSlider  = GetComponentInChildren <v_SpriteHealth>();
            head          = animator.GetBoneTransform(HumanBodyBones.Head);
            oldPosition   = transform.position;
            currentHealth = maxHealth;
            startPosition = transform.position;
        }
Example #3
0
 private void ActiveSecundaryWeapon()
 {
     if (secundaryWeapon)
     {
         secundaryWeapon.gameObject.SetActive(true);
     }
     else
     {
         secundaryWeapon = Instantiate(secundaryWeaponPrefab);
         secundaryWeapon.transform.parent           = otherSideTransform;
         secundaryWeapon.transform.localPosition    = Vector3.zero;
         secundaryWeapon.transform.localEulerAngles = Vector3.zero;
     }
     if (!manager)
     {
         manager = GetComponentInParent <vMeleeManager>();
     }
     if (manager)
     {
         manager.SetLeftWeapon(secundaryWeapon);
     }
 }
    public override void OnInspectorGUI()
    {
        if (!skin)
        {
            skin = Resources.Load("skin") as GUISkin;
        }
        GUI.skin = skin;

        vMeleeManager meleeEquip = (vMeleeManager)target;

        _meleeObject = new SerializedObject(target);
        serializedObject.Update();
        if (!meleeEquip || _meleeObject == null)
        {
            return;
        }

        GUILayout.BeginVertical("Melee Manager by Invector", "window");
        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical();
        if (!AnimatorCheck())
        {
            return;
        }

        DrawHitPropertiesInfo();
        DrawDefaultHitboxInfo();
        DrawMeleeWeaponInfo();

        GUILayout.EndVertical();
        EditorGUILayout.EndVertical();
        if (GUI.changed)
        {
            EditorUtility.SetDirty(meleeEquip);
            serializedObject.ApplyModifiedProperties();
        }
    }
 void Start()
 {
     manager = GetComponentInParent <vMeleeManager>();
     time    = timeToInvoke;
 }
 partial void _CreateDefaultEquipPoints(vItemManager itemManager, vMeleeManager meleeManager);
 public static void CreateDefaultEquipPoints(vItemManager itemManager, vMeleeManager meleeManager)
 {
     instance = new vItemManagerUtilities();
     instance._CreateDefaultEquipPoints(itemManager, meleeManager);
     instance._InitItemManager(itemManager);
 }
Example #8
0
        /// <summary>
        /// Create button event, adds all components.
        /// </summary>
        void Create()
        {
            if (Selection.activeGameObject != null)
            {  // fail safe
                // add melee manager for when shooter
                if (!Selection.activeGameObject.GetComponent <vMeleeManager>())
                {
                    Selection.activeGameObject.AddComponent <vMeleeManager>();
                }

                // inventory
                vItemManager itemManager = Selection.activeGameObject.GetComponent <vItemManager>();
                if (!itemManager)
                {
                    itemManager = Selection.activeGameObject.AddComponent <vItemManager>();
                    vItemManagerUtilities.CreateDefaultEquipPoints(itemManager, itemManager.GetComponent <vMeleeManager>());
                }
                itemManager.inventoryPrefab = InventoryPrefab;
                itemManager.itemListData    = ItemListData;
                itemManager.itemsFilter.Add(vItemType.MeleeWeapon);
                itemManager.itemsFilter.Add(vItemType.Spell);

                // hit damage particle
                vHitDamageParticle hitDamageParticle = Selection.activeGameObject.GetComponent <vHitDamageParticle>();
                if (!hitDamageParticle)
                {
                    hitDamageParticle = Selection.activeGameObject.AddComponent <vHitDamageParticle>();
                }
                hitDamageParticle.defaultDamageEffect = HitDamageParticle;

                // UI
                GameObject goItemCollectionDisplay = PrefabUtility.InstantiatePrefab(ItemCollectionDisplay) as GameObject;
                goItemCollectionDisplay.transform.SetParent(UIBase.transform);
                GameObject goInventoryPrefab = PrefabUtility.InstantiatePrefab(InventoryPrefab.gameObject) as GameObject;
                goInventoryPrefab.name = "Inventory_MeleeMagic_Auto";


                // leveling system
                CharacterInstance levelingsystem = Selection.activeGameObject.GetComponent <CharacterInstance>();
                if (!levelingsystem)
                {
                    levelingsystem = Selection.activeGameObject.AddComponent <CharacterInstance>();
                }

                // link the invector character damage event to the leveling system
                vThirdPersonController thirdp = Selection.activeGameObject.GetComponent <vThirdPersonController>();
                UnityEventTools.AddPersistentListener(thirdp.onReceiveDamage, levelingsystem.OnRecieveDamage);

                // link the melee manager hits to the leveling system
                vMeleeManager meleeM = Selection.activeGameObject.GetComponent <vMeleeManager>();
                if (meleeM)
                {
                    if (meleeM.onDamageHit == null)
                    {
                        meleeM.onDamageHit = new vOnHitEvent();
                    }
                    UnityEventTools.AddPersistentListener(meleeM.onDamageHit, levelingsystem.OnSendHit);
                }

                // add conditions and update particles to use the LOD 1 mesh
                levelingsystem.Conditions = new List <BaseCondition>();
                levelingsystem.Conditions.Add(new BaseCondition()
                {
                    Type = BaseDamage.Physical
                });
                GameObject goConditionsRoot = new GameObject("Conditions");
                goConditionsRoot.transform.SetParent(Selection.activeGameObject.transform);
                goConditionsRoot.transform.position = new Vector3(0f, 0f, 0f);
                foreach (BaseCondition bc in Conditions)
                {
                    GameObject goCondition = null;
                    if (bc.Display)
                    {
                        // load the prefab
                        goCondition = PrefabUtility.InstantiatePrefab(bc.Display) as GameObject;
                        goCondition.transform.SetParent(goConditionsRoot.transform);
                        goCondition.transform.position = new Vector3(0f, 0f, 0f);

                        // update all particles to use the mesh renderer from LOD1
                        goCondition.SetActive(true);
                        ParticleSystem[] ConditionParticles = goCondition.GetComponentsInChildren <ParticleSystem>();
                        foreach (ParticleSystem p in ConditionParticles)
                        {
                            if (p.shape.enabled)
                            {
                                if (p.shape.shapeType == ParticleSystemShapeType.SkinnedMeshRenderer)
                                {
                                    ParticleSystem.ShapeModule editableShape = p.shape;
                                    editableShape.skinnedMeshRenderer = LOD1BodyMesh[iWhichMesh];
                                }
                            }
                        }
                        goCondition.SetActive(false);
                    }

                    // add to the levelling system
                    levelingsystem.Conditions.Add(new BaseCondition()
                    {
                        Type = bc.Type, Length = 0, Display = goCondition
                    });
                }

                // add the magic spawn point
                GameObject goMagicSpawn = new GameObject("Magic Spawn");
                goMagicSpawn.transform.SetParent(Selection.activeGameObject.transform);
                goMagicSpawn.transform.position = new Vector3(0f, 1.5f, 0.9f);

                // magic input
                MagicSettings magicIO = Selection.activeGameObject.GetComponent <MagicSettings>();
                if (!magicIO)
                {
                    magicIO = Selection.activeGameObject.AddComponent <MagicSettings>();
                }
                magicIO.PooledMagic     = true;
                magicIO.MagicSpawnPoint = goMagicSpawn.transform;
                magicIO.onUseMana       = new UnityIntEvent();
                UnityEventTools.AddPersistentListener(magicIO.onUseMana, levelingsystem.UseMana);


#if !VANILLA                                                                                                         // set spell triggers F1-F5
                GameObject goInventoryWindow    = goInventoryPrefab.transform.Find("InventoryWindow").gameObject;    // grab inventory window
                GameObject goEquipmentInventory = goInventoryWindow.transform.Find("EquipmentInventory").gameObject; // and the equip slot parent
                goEquipmentInventory.SetActive(true);                                                                // enable for component search
                int          iNext    = 1;
                vEquipSlot[] allSlots = goInventoryPrefab.GetComponentsInChildren <vEquipSlot>();
                foreach (vEquipSlot slot in allSlots)
                {
                    if (slot.transform.parent.parent.name == "EquipMentArea_Spells")
                    {                                                                                                      // is a spell inventory area
                        MagicSpellTrigger trigger = new MagicSpellTrigger();                                               // create the trigger
                        trigger.EquipSlots     = new vEquipSlot[] { slot };                                                // set the inventory slot
                        trigger.Input          = new GenericInput("F" + iNext.ToString(), null, null);                     // set the input key
                        trigger.Input.useInput = true;                                                                     // enable
                        vEquipmentDisplay[] allDisplays = goInventoryPrefab.GetComponentsInChildren <vEquipmentDisplay>(); // find all displays
                        foreach (vEquipmentDisplay disp in allDisplays)
                        {                                                                                                  // check all
                            if (disp.gameObject.name == slot.gameObject.name.Replace("EquipSlot ", "EquipDisplay_Spell "))
                            {                                                                                              // found matching name?
                                trigger.EquipDisplay = disp;                                                               // success, apply
                                UnityEventTools.AddPersistentListener(slot.onAddItem, magicIO.SpellEquiped);               // listen for spells equiped
                                UnityEventTools.AddPersistentListener(slot.onRemoveItem, magicIO.SpellUnEquiped);          // and unequiped
                                break;                                                                                     // drop out
                            }
                        }
                        magicIO.SpellsTriggers.Add(trigger); // add the trigger
                        iNext += 1;                          // next please
                    }
                }
                goEquipmentInventory.SetActive(false);  // deactivate the inventory display
#endif

                // link the UI further
                Transform tHUD = UIBase.transform.Find("HUD");
                magicIO.XPText      = tHUD.Find("XP").GetComponent <UnityEngine.UI.Text>();
                magicIO.LevelText   = tHUD.Find("Level").GetComponent <UnityEngine.UI.Text>();
                magicIO.LevelUpText = tHUD.Find("Level up").GetComponent <UnityEngine.UI.Text>();
                magicIO.ManaSlider  = tHUD.Find("mana").GetComponent <UnityEngine.UI.Slider>();

#if !VANILLA
                itemManager.onUseItem = new OnHandleItemEvent();
                UnityEventTools.AddPersistentListener(itemManager.onUseItem, magicIO.UsePotion);

                // also lock input when inventory open
                itemManager.onOpenCloseInventory = new OnOpenCloseInventory();
                vMeleeCombatInput MeleeInput = Selection.activeGameObject.GetComponent <vMeleeCombatInput>();
                if (MeleeInput)
                {
                    UnityEventTools.AddPersistentListener(itemManager.onOpenCloseInventory, MeleeInput.SetLockMeleeInput);
                }
#endif
                // work complete
                this.Close();
            }
            else
            {
                Debug.Log("Please select the Player to add these components.");
            }
        }
Example #9
0
        IEnumerator Start()
        {
            itemCollection = GetComponentInChildren <vItemCollection>(true);
            ai             = GetComponent <v_AIController>();
            manager        = GetComponent <vMeleeManager>();
            yield return(new WaitForEndOfFrame());

            if (itemCollection && ai && manager)
            {
                ai.onSetAgressive.AddListener(OnSetAgressive);
                leftArm  = ai.animator.GetBoneTransform(HumanBodyBones.LeftLowerArm);
                rightArm = ai.animator.GetBoneTransform(HumanBodyBones.RightLowerArm);

                for (int i = 0; i < itemCollection.items.Count; i++)
                {
                    if (itemCollection.items[i].amount > 0)
                    {
                        var item = itemCollection.itemListData.items.Find(_item => _item.id == itemCollection.items[i].id && _item.type == vItemType.MeleeWeapon);
                        if (item != null)
                        {
                            AddItem(itemCollection.items[i].id, itemCollection.items[i].amount);
                        }
                    }
                }

                if (useRightWeapon)
                {
                    if (randomRightWeapon)
                    {
                        GetRandomWeapon(ref rightWeaponItem, vMeleeType.OnlyAttack);
                    }
                    else
                    {
                        GetItemWeapon(rightWeaponID, ref rightWeaponItem, vMeleeType.OnlyAttack);
                    }
                }

                if (useLeftWeapon)
                {
                    if (randomLeftWeapon)
                    {
                        GetRandomWeapon(ref leftWeaponItem, vMeleeType.OnlyDefense);
                    }
                    else
                    {
                        GetItemWeapon(leftWeaponID, ref leftWeaponItem, vMeleeType.OnlyDefense);
                    }
                }

                if (rightArm && rightWeaponItem)
                {
                    Transform equipPoint = null;
                    if (customEquipPointR.Count > 0)
                    {
                        equipPoint = customEquipPointR.Find(t => t.name == rightWeaponItem.customHandler);
                    }

                    if (equipPoint == null)
                    {
                        equipPoint = defaultEquipPointR;
                    }

                    if (equipPoint)
                    {
                        rightWeapon = Instantiate(rightWeaponItem.originalObject) as GameObject;
                        rightWeapon.transform.parent           = equipPoint;
                        rightWeapon.transform.localPosition    = Vector3.zero;
                        rightWeapon.transform.localEulerAngles = Vector3.zero;
                        manager.SetRightWeapon(rightWeapon);
                        rightWeapon.SetActive(false);
                        if (ai.agressiveAtFirstSight)
                        {
                            StartCoroutine(EquipItemRoutine(false, rightWeaponItem, rightWeapon));
                        }
                    }
                }

                if (leftArm && leftWeaponItem)
                {
                    Transform equipPoint = null;
                    if (customEquipPointL.Count > 0)
                    {
                        equipPoint = customEquipPointL.Find(t => t.name == leftWeaponItem.customHandler);
                    }

                    if (equipPoint == null)
                    {
                        equipPoint = defaultEquipPointL;
                    }

                    if (equipPoint)
                    {
                        leftWeapon = Instantiate(leftWeaponItem.originalObject) as GameObject;
                        leftWeapon.transform.parent           = equipPoint;
                        leftWeapon.transform.localPosition    = Vector3.zero;
                        leftWeapon.transform.localEulerAngles = Vector3.zero;
                        var scale = leftWeapon.transform.localScale;
                        scale.x *= -1;
                        leftWeapon.transform.localScale = scale;
                        manager.SetLeftWeapon(leftWeapon);
                        leftWeapon.SetActive(false);
                        if (ai.agressiveAtFirstSight)
                        {
                            StartCoroutine(EquipItemRoutine(true, leftWeaponItem, leftWeapon));
                        }
                    }
                }
            }
        }
Example #10
0
 void Start()
 {
     manager = GetComponentInParent <vMeleeManager>();
 }
Example #11
0
    /// <summary>
    /// Call Back of hitboxes
    /// </summary>
    /// <param name="hitBox">vHitBox object</param>
    /// <param name="other">target Collider</param>
    public virtual void OnHit(vHitBox hitBox, Collider other)
    {
        //Check  first contition for hit
        if (canApplyDamage && !targetColliders[hitBox].Contains(other.gameObject) && (meleeManager != null && other.gameObject != meleeManager.gameObject))
        {
            var inDamage = false;
            var inRecoil = false;
            if (meleeManager == null)
            {
                meleeManager = GetComponentInParent <vMeleeManager>();
            }
            //check if meleeManager exist and apply  his hitProperties  to this
            HitProperties _hitProperties = meleeManager.hitProperties;

            /// Damage Conditions
            if (((hitBox.triggerType & vHitBoxType.Damage) != 0) && _hitProperties.hitDamageTags == null || _hitProperties.hitDamageTags.Count == 0)
            {
                inDamage = true;
            }
            else if (((hitBox.triggerType & vHitBoxType.Damage) != 0) && _hitProperties.hitDamageTags.Contains(other.tag))
            {
                inDamage = true;
            }
            else   ///Recoil Conditions
            if (((hitBox.triggerType & vHitBoxType.Recoil) != 0) && (_hitProperties.hitRecoilLayer == (_hitProperties.hitRecoilLayer | (1 << other.gameObject.layer))))
            {
                inRecoil = true;
            }
            if (inDamage || inRecoil)
            {
                ///add target collider in list to control frequency of hit him
                targetColliders[hitBox].Add(other.gameObject);
                vHitInfo hitInfo = new vHitInfo(this, hitBox, other, hitBox.transform.position);
                if (inDamage == true)
                {
                    /// If meleeManager
                    /// call onDamageHit to control damage values
                    /// and  meleemanager will call the ApplyDamage after to filter the damage
                    /// if meleeManager is null
                    /// The damage will be  directly applied
                    /// Finally the OnDamageHit event is called
                    if (meleeManager)
                    {
                        meleeManager.OnDamageHit(hitInfo);
                    }
                    else
                    {
                        damage.sender = transform;
                        ApplyDamage(hitBox, other, damage);
                    }
                    onDamageHit.Invoke(hitInfo);
                }
                /// Recoil just work with OnRecoilHit event and meleeManger
                if (inRecoil == true)
                {
                    if (meleeManager)
                    {
                        meleeManager.OnRecoilHit(hitInfo);
                    }
                    onRecoilHit.Invoke(hitInfo);
                }
            }
        }
    }
 protected override void Start()
 {
     base.Start();
     meleeManager = gameObject.GetComponent <vMeleeManager>();
 }
        /// <summary>
        /// Create button event, adds all components.
        /// </summary>
        void Create()
        {
            if (Selection.activeGameObject != null)
            {  // fail safe
                // hit damage particle
                vHitDamageParticle hitDamageParticle = Selection.activeGameObject.GetComponent <vHitDamageParticle>();
                if (!hitDamageParticle)
                {
                    hitDamageParticle = Selection.activeGameObject.AddComponent <vHitDamageParticle>();
                }
                hitDamageParticle.defaultDamageEffect = HitDamageParticle;

                // melee manager
                vMeleeManager meleeManager = Selection.activeGameObject.GetComponent <vMeleeManager>();
                if (!meleeManager)
                {
                    meleeManager = Selection.activeGameObject.AddComponent <vMeleeManager>();
                }
                meleeManager.hitProperties = new HitProperties();
                meleeManager.hitProperties.hitDamageTags[0] = "Player";

                // leveling system
                CharacterInstance levelingsystem = Selection.activeGameObject.GetComponent <CharacterInstance>();
                if (!levelingsystem)
                {
                    levelingsystem = Selection.activeGameObject.AddComponent <CharacterInstance>();
                }

                // add conditions and update particles to use the LOD 1 mesh
                levelingsystem.Conditions = new List <BaseCondition>();
                levelingsystem.Conditions.Add(new BaseCondition()
                {
                    Type = BaseDamage.Physical
                });
                GameObject goConditionsRoot = new GameObject("Conditions");
                goConditionsRoot.transform.SetParent(Selection.activeGameObject.transform);
                goConditionsRoot.transform.position = new Vector3(0f, 0f, 0f);
                foreach (BaseCondition bc in Conditions)
                {
                    GameObject goCondition = null;
                    if (bc.Display)
                    {
                        // load the prefab
                        goCondition = PrefabUtility.InstantiatePrefab(bc.Display) as GameObject;
                        goCondition.transform.SetParent(goConditionsRoot.transform);
                        goCondition.transform.position = new Vector3(0f, 0f, 0f);

                        // update all particles to use the mesh renderer from LOD1
                        goCondition.SetActive(true);
                        ParticleSystem[] ConditionParticles = goCondition.GetComponentsInChildren <ParticleSystem>();
                        foreach (ParticleSystem p in ConditionParticles)
                        {
                            if (p.shape.enabled)
                            {
                                if (p.shape.shapeType == ParticleSystemShapeType.SkinnedMeshRenderer)
                                {
                                    ParticleSystem.ShapeModule editableShape = p.shape;
                                    editableShape.skinnedMeshRenderer = LOD1BodyMesh[iWhichMesh];
                                }
                            }
                        }
                        goCondition.SetActive(false);
                    }

                    // add to the levelling system
                    levelingsystem.Conditions.Add(new BaseCondition()
                    {
                        Type = bc.Type, Length = 0, Display = goCondition
                    });
                }

                // link the ai damage to the leveling system
                v_AIController vai = Selection.activeGameObject.GetComponent <v_AIController>();
                vai.onReceiveDamage = new Invector.OnReceiveDamage();
                UnityEventTools.AddPersistentListener(vai.onReceiveDamage, levelingsystem.OnRecieveDamage);

                // link the melee manager hits to the leveling system
                meleeManager.onDamageHit = new vOnHitEvent();
                UnityEventTools.AddPersistentListener(meleeManager.onDamageHit, levelingsystem.OnSendHit);

                // add the magic spawn point
                GameObject goMagicSpawn = new GameObject("Magic Spawn");
                goMagicSpawn.transform.SetParent(Selection.activeGameObject.transform);
                goMagicSpawn.transform.position = new Vector3(0f, 1.5f, 0.9f);

                // AI inventory
                MagicAIItemManager itemManager = Selection.activeGameObject.GetComponent <MagicAIItemManager>();
                if (!itemManager)
                {
                    itemManager = Selection.activeGameObject.AddComponent <MagicAIItemManager>();
                }
                itemManager.itemListData = ItemListData;
                itemManager.itemsFilter.Add(vItemType.Spell);

                // Magic AI
                MagicAI mai = Selection.activeGameObject.GetComponent <MagicAI>();
                if (!mai)
                {
                    mai = Selection.activeGameObject.AddComponent <MagicAI>();
                }
                mai.MagicSpawnPoint = goMagicSpawn.transform;

                // health/mana bars
                GameObject HealthUIinstance = (GameObject)Instantiate(HealthUI);
                HealthUIinstance.transform.SetParent(HeadBone);
                HealthUIinstance.transform.localPosition = HealthUI.transform.localPosition;
                HealthUIinstance.transform.localRotation = HealthUI.transform.localRotation;
                HealthUIinstance.transform.localScale    = HealthUI.transform.localScale;

                // work complete
                this.Close();
            }
            else
            {
                Debug.Log("Please select the Player to add these components.");
            }
        }
        public void Init()
        {
            // this method is called on the ThirdPersonController or TopDownController - Start

            animator     = GetComponent <Animator>();
            tpCamera     = v3rdPersonCamera.instance;
            hud          = vHUDController.instance;
            meleeManager = GetComponent <vMeleeManager>();
            // create a offset pivot to the character, to align camera position when transition to ragdoll
            var hips = animator.GetBoneTransform(HumanBodyBones.Hips);

            offSetPivot = Vector3.Distance(transform.position, hips.position);

            if (tpCamera != null)
            {
                tpCamera.offSetPlayerPivot = offSetPivot;
                tpCamera.target            = transform;
            }

            if (hud == null)
            {
                Debug.LogWarning("Invector : Missing HUDController, please assign on ThirdPersonController");
            }

            // prevents the collider from slipping on ramps
            frictionPhysics                 = new PhysicMaterial();
            frictionPhysics.name            = "frictionPhysics";
            frictionPhysics.staticFriction  = 1f;
            frictionPhysics.dynamicFriction = 1f;

            // default physics
            slippyPhysics                 = new PhysicMaterial();
            slippyPhysics.name            = "slippyPhysics";
            slippyPhysics.staticFriction  = 0f;
            slippyPhysics.dynamicFriction = 0f;

            // rigidbody info
            _rigidbody = GetComponent <Rigidbody>();

            // capsule collider
            _capsuleCollider = GetComponent <CapsuleCollider>();

            // save your collider preferences
            colliderCenter = GetComponent <CapsuleCollider>().center;
            colliderRadius = GetComponent <CapsuleCollider>().radius;
            colliderHeight = GetComponent <CapsuleCollider>().height;

            // health info
            currentHealth = maxHealth;
            currentHealthRecoveryDelay = healthRecoveryDelay;
            currentStamina             = maxStamina;

            // stopmove info
            canMoveForward = true;
            canMoveRight   = true;
            canMoveLeft    = true;
            canMoveBack    = true;

            if (hud == null)
            {
                return;
            }

            hud.damageImage.color = new Color(0f, 0f, 0f, 0f);

            cameraTransform.SendMessage("Init", SendMessageOptions.DontRequireReceiver);
            UpdateHUD();
        }