/// <summary> /// Grabs various components and inits stuff /// </summary> public virtual void Setup() { _character = this.gameObject.GetComponentInParent <Character>(); _characterGridMovement = _character?.FindAbility <CharacterGridMovement>(); _weaponModels = new List <WeaponModel>(); foreach (WeaponModel model in _character.gameObject.GetComponentsInChildren <WeaponModel>()) { _weaponModels.Add(model); } CharacterAnimator = _animator; // filler if the WeaponAttachment has not been set if (WeaponAttachment == null) { WeaponAttachment = transform; } if ((_animator != null) && (AutoIK)) { _weaponIK = _animator.GetComponent <WeaponIK>(); } // we set the initial weapon if (InitialWeapon != null) { ChangeWeapon(InitialWeapon, InitialWeapon.WeaponName, false); } }
/// <summary> /// Grabs animator, weaponIK, hashes the animation parameter names, and stores initial positions /// </summary> protected virtual void Initialization() { _weaponIK = this.gameObject.GetComponent <WeaponIK>(); _animator = this.gameObject.GetComponent <Animator>(); _animationParametersHashes = new List <int>(); foreach (string _animationParameterName in AnimationParametersPreventingIK) { int newHash = Animator.StringToHash(_animationParameterName); _animationParametersHashes.Add(newHash); } if (WeaponAttachment != null) { _initialParent = WeaponAttachment.parent; _initialLocalPosition = WeaponAttachment.transform.localPosition; _initialLocalScale = WeaponAttachment.transform.localScale; _initialRotation = WeaponAttachment.transform.rotation; } }
/// <summary> /// Grabs various components and inits stuff /// </summary> public virtual void Setup() { _character = this.gameObject.MMGetComponentNoAlloc <Character>(); _characterGridMovement = this.gameObject.GetComponent <CharacterGridMovement>(); CharacterAnimator = _animator; // filler if the WeaponAttachment has not been set if (WeaponAttachment == null) { WeaponAttachment = transform; } if ((_animator != null) && (AutoIK)) { _weaponIK = _animator.GetComponent <WeaponIK>(); } // we set the initial weapon if (InitialWeapon != null) { ChangeWeapon(InitialWeapon, null); } }