Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class TurnBone : MonoBehaviour
  4. {
  5.     [SerializeField] private bool additive = true;
  6.     [SerializeField] private Vector3 targetRotation = Vector3.zero;
  7.  
  8.     public void Apply(float turn)
  9.     {
  10.         var t = (turn + 1f) / 2f;
  11.         var current = transform.localEulerAngles;
  12.         var angles = Vector3.Lerp(-targetRotation, targetRotation, t);
  13.  
  14.         if (additive)
  15.             current += angles;
  16.         else
  17.             current = angles;
  18.        
  19.         transform.localEulerAngles = current;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement