Question by 
               Okplayback · Oct 30, 2016 at 12:23 PM · 
                rotationvector3quaternionrotate objectrotating  
              
 
              Rotating 3d person character
Hi All, I need your help. I have script to rotate my character via joystick.
 public class PlayerController : MonoBehaviour {
 
     [SerializeField]
     private Animator animator;
     [SerializeField]
     private float directionDampTime = .25f;
     private float speed = 0.0f;
     private float h = 0.0f;
     private float v = 0.0f;
     private float turnSmoothing = 2f;
 
     void Start () {
     
         animator = GetComponent<Animator>();
         if (animator.layerCount >= 2) {
             animator.SetLayerWeight (1, 1);
         }
     }
     
 
     void Update () {
     
         if (animator) {
             h = CrossPlatformInputManager.GetAxis ("Horizontal");
             v = CrossPlatformInputManager.GetAxis ("Vertical");
 
             speed = new Vector2 (h, v).sqrMagnitude;
             animator.SetFloat ("Speed", speed);
             animator.SetFloat ("Direction", h, directionDampTime, Time.deltaTime);
             if (speed > 0) {
                 RotatingPlayer (h, v);        
             }
         }
     }
 
     void RotatingPlayer(float horizontal, float vertical)
     {
         Vector3 targetDirection = new Vector3 (horizontal, 0.0f, vertical);
         Quaternion targetRotation = Quaternion.LookRotation (targetDirection, Vector3.up);
         Quaternion newRotation = Quaternion.Lerp (transform.rotation, targetRotation, turnSmoothing * Time.deltaTime);
         transform.rotation = newRotation;
     }
 
 }
 
               So, I don't understand how to work with vectors and quaternions, and i need character move to joystick direction relatively own face, but not relatively world coordinates...how to do this? I tried to illustrate what i need, hope it's clear. 
 p.s. sorry for english)
 
                 
                безымянныи.png 
                (32.7 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Rotation Perpendicular to Line Segment 1 Answer
Get angle between direction and plane 1 Answer
rotate an object with HTC Vive controller 0 Answers
How to use Quaternion.Slerp with transform.LookAt? 3 Answers
Why isn't my steering wheel working? 0 Answers