Character snaps back to front and cannot rotate the full 360 degrees.,Character Rotates back to front and cannot turn full range
Hello, I have been using Sebastien Lagues code in my unity game. I have a simple blend tree with idle, walk and run. I have used his code (below) but when I am rotated 90 degrees with the 'a' or 'd' key and press w, it rotates back to the front. The other problem is that when I press 'a' or 'd' it doesn't rotate further then 90 degrees.
CODE:
 using UnityEngine;
 using System.Collections;
 
 public class controller : MonoBehaviour {
 
     public float walkSpeed = 2;
     public float runSpeed = 6;
 
     public float turnSmoothTime = 0.2f;
     float turnSmoothVelocity;
 
     public float speedSmoothTime = 0.1f;
     float speedSmoothVelocity;
     float currentSpeed;
 
     Animator animator;
 
     void Start () {
         animator = GetComponent<Animator> ();
     }
 
     void Update () {
 
         Vector2 input = new Vector2 (Input.GetAxisRaw ("Horizontal"), Input.GetAxisRaw ("Vertical"));
         Vector2 inputDir = input.normalized;
 
         if (inputDir != Vector2.zero) {
             float targetRotation = Mathf.Atan2 (inputDir.x, inputDir.y) * Mathf.Rad2Deg;
             transform.eulerAngles = Vector3.up * Mathf.SmoothDampAngle(transform.eulerAngles.y, targetRotation, ref turnSmoothVelocity, turnSmoothTime);
         }
 
         bool running = Input.GetKey (KeyCode.LeftShift);
         float targetSpeed = ((running) ? runSpeed : walkSpeed) * inputDir.magnitude;
         currentSpeed = Mathf.SmoothDamp (currentSpeed, targetSpeed, ref speedSmoothVelocity, speedSmoothTime);
 
         transform.Translate (transform.forward * currentSpeed * Time.deltaTime, Space.World);
 
         float animationSpeedPercent = ((running) ? 1 : .5f) * inputDir.magnitude;
         animator.SetFloat ("Speed", animationSpeedPercent, speedSmoothTime, Time.deltaTime);
 
     }
 }
If anyone can shed some light on the problam, it would be great as have been stuck on this for a couple of days. Many Thanks, Thomas
Your answer
 
 
             Follow this Question
Related Questions
How do I know what animation I can transit to in the animator, from my current animation? 0 Answers
Why is the last frame of the animation not triggering? 0 Answers
How do you make sure that when you land on an object, an animation starts? 0 Answers
Animation from child object overrided by its parent and won't show in game window 0 Answers
Animator behaving weirdly 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                