Advertisement
AndrewRosyaev

PlayerHeadControl.cs 6

Dec 9th, 2015
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PlayerHeadControl : MonoBehaviour
  5. {
  6.     private Animator anim;
  7.     private float x;
  8.     private float y;
  9.     public float SpeedRotation;
  10.  
  11.     // Use this for initialization
  12.     void Start ()
  13.     {
  14.         anim = GetComponent<Animator> ();
  15.     }
  16.    
  17.     // Update is called once per frame
  18.     void Update ()
  19.     {
  20.         x += Input.GetAxis ("Mouse X") * SpeedRotation * 0.05f;
  21.         x = Mathf.Clamp (x,-35,35);
  22.         y += Input.GetAxis ("Mouse Y") * SpeedRotation * 0.05f;
  23.         y = Mathf.Clamp (y,-20,20);
  24.         anim.SetFloat ("HeadX", -x);
  25.         anim.SetFloat ("HeadY", y);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement