SHARE
TWEET

Untitled

a guest Dec 15th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top