Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PlayerControllerScript : MonoBehaviour
- {
- Animator anim;
- bool goingRight=false;
- void Start()
- {
- anim = GetComponent<Animator> ();
- }
- void Update ()
- {
- if (Input.GetKeyDown (KeyCode.D))
- {
- goingRight = true;
- anim.SetBool("goingRight", true);
- }
- if (Input.GetKeyUp (KeyCode.D))
- {
- goingRight = false;
- anim.SetBool("goingRight", false);
- }
- if(goingRight) transform.Translate (Vector2.right * Time.deltaTime * 5);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement