Advertisement
Guest User

Untitled

a guest
Feb 7th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. public class PlayerControllerScript : MonoBehaviour
  2. {
  3.     Animator anim;
  4.     bool goingRight=false;
  5.  
  6.         void Start()
  7.         {
  8.                 anim = GetComponent<Animator> ();
  9.         }
  10.  
  11.         void Update ()
  12.         {
  13.                 if (Input.GetKeyDown (KeyCode.D))
  14.                 {
  15.             goingRight = true;
  16.                         anim.SetBool("goingRight", true);
  17.                 }
  18.                 if (Input.GetKeyUp (KeyCode.D))
  19.                 {
  20.             goingRight = false;
  21.                         anim.SetBool("goingRight", false);
  22.                 }
  23.  
  24.         if(goingRight) transform.Translate (Vector2.right * Time.deltaTime * 5);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement