private void Start() { states = GetComponent <StateManager>(); states.aiManager = this; agent = GetComponentInChildren <NavMeshAgent>(); if (currentActionsHolder != null) { AIAction hightest = currentActionsHolder.FindHighestScoreAction(this); currentAction = hightest; } weaponHook = GetComponentInChildren <WeaponHook>(); if (weaponHook != null) { weaponHook.Init(); } }
public void LoadWeapon(Weapon targetWeapon) { GameObject go = Instantiate(targetWeapon.modelPrefab) as GameObject; Transform rh = anim.GetBoneTransform(HumanBodyBones.RightHand); go.transform.parent = rh; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; WeaponHook hook = go.GetComponent <WeaponHook>(); hook.Init(targetWeapon); currentWeaponHook = hook; GameObject aimPivot = Instantiate(targetWeapon.aimPivotPrefab) as GameObject; Transform rh_ik = aimPivot.transform.GetChild(0); aimPivot.transform.parent = this.transform; animatorHook.LoadCurrentWeapon(currentWeaponHook, aimPivot.transform, rh_ik); }