Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class TurnBone : MonoBehaviour
- {
- [SerializeField] private bool additive = true;
- [SerializeField] private Vector3 targetRotation = Vector3.zero;
- public void Apply(float turn)
- {
- var t = (turn + 1f) / 2f;
- var current = transform.localEulerAngles;
- var angles = Vector3.Lerp(-targetRotation, targetRotation, t);
- if (additive)
- current += angles;
- else
- current = angles;
- transform.localEulerAngles = current;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement