Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PULSO_FingersAnimator : MonoBehaviour {
- public Transform[] _f0Bones;
- Quaternion[] _f0StartRots;
- public Transform[] _f1Bones;
- Quaternion[] _f1StartRots;
- public Transform[] _f2Bones;
- Quaternion[] _f2StartRots;
- public Transform[] _f3Bones;
- Quaternion[] _f3StartRots;
- public Transform[] _f4Bones;
- Quaternion[] _f4StartRots;
- [Range(0f, 1f)]
- public float _f0Angle = 1;
- [Range(0f, 1f)]
- public float _f1Angle = 1;
- [Range(0f, 1f)]
- public float _f2Angle = 1;
- [Range(0f, 1f)]
- public float _f3Angle = 1;
- [Range(0f, 1f)]
- public float _f4Angle = 1;
- [Range(0f, 1f)]
- public float _f5Angle = 1;
- public float _from;
- public float _to;
- public float _fromB;
- public float _toB;
- public float _fromBS;
- public float _toBS;
- void Start ()
- {
- _f0StartRots = new Quaternion[_f0Bones.Length];
- for (int i = 0; i < _f0Bones.Length; i++) {
- _f0StartRots [i] = _f0Bones [i].localRotation;
- }
- _f1StartRots = new Quaternion[_f1Bones.Length];
- for (int i = 0; i < _f1Bones.Length; i++) {
- _f1StartRots [i] = _f1Bones [i].localRotation;
- }
- _f2StartRots = new Quaternion[_f2Bones.Length];
- for (int i = 0; i < _f2Bones.Length; i++) {
- _f2StartRots [i] = _f2Bones [i].localRotation;
- }
- _f3StartRots = new Quaternion[_f3Bones.Length];
- for (int i = 0; i < _f3Bones.Length; i++) {
- _f3StartRots [i] = _f3Bones [i].localRotation;
- }
- _f4StartRots = new Quaternion[_f4Bones.Length];
- for (int i = 0; i < _f4Bones.Length; i++) {
- _f4StartRots [i] = _f4Bones [i].localRotation;
- }
- }
- void LateUpdate()
- {
- if (WeaponManager._instance != null)
- {
- if (WeaponManager._instance._selectedGun != -1)
- {
- if (WeaponManager._instance._selectedGun == 0 || WeaponManager._instance._selectedGun == 1)
- {
- _f1Bones [2].localRotation = _f1StartRots [2] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f1Angle));
- }
- if (WeaponManager._instance._selectedGun == 2)
- {
- for (int i = 0; i < _f0Bones.Length; i++)
- {
- _f0Bones [i].localRotation = _f0StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f0Angle));
- }
- }
- }
- }
- }
- void Update ()
- {
- for (int i = 0; i < _f0Bones.Length; i++)
- {
- _f0Bones [i].localRotation = _f0StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_fromB, _toB, _f0Angle));
- }
- for (int i = 0; i < _f1Bones.Length; i++)
- {
- _f1Bones [i].localRotation = _f1StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f1Angle));
- }
- for (int i = 0; i < _f2Bones.Length; i++)
- {
- _f2Bones [i].localRotation = _f2StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f2Angle));
- }
- for (int i = 0; i < _f3Bones.Length; i++)
- {
- _f3Bones [i].localRotation = _f3StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f3Angle));
- }
- for (int i = 0; i < _f4Bones.Length; i++)
- {
- _f4Bones [i].localRotation = _f4StartRots [i] * Quaternion.Euler (0f, 0f, Mathf.Lerp (_from, _to, _f4Angle));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement