Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PlayerController : MonoBehaviour {
- private Animator animator;
- void Start()
- {
- animator = this.GetComponent<Animator>();
- animator.SetInteger("Move", 0);
- animator.SetFloat("idles", 2);
- }
- void Update()
- {
- Flip();
- movement();
- void movement()
- {
- if (Input.GetKey(KeyCode.S))
- {
- this.transform.position += new Vector3(0f, -0.04f, 0f);
- }
- if (Input.GetKey(KeyCode.W))
- {
- this.transform.position += new Vector3(0f, 0.04f, 0f);
- }
- if (Input.GetKey(KeyCode.D))
- {
- this.transform.position += new Vector3(0.04f, 0f, 0f);
- }
- else if (Input.GetKey(KeyCode.A))
- {
- this.transform.position += new Vector3(-0.04f, 0f, 0f);
- }
- }
- void Flip()
- {
- if (Input.GetKey(KeyCode.S))
- {
- this.transform.localScale = new Vector3(1, 1, 1);
- }
- if (Input.GetKey(KeyCode.W))
- {
- this.transform.localScale = new Vector3(1, 1, 1);
- }
- if (Input.GetKey(KeyCode.A))
- {
- this.transform.localScale = new Vector3(-1, 1, 1);
- }
- if (Input.GetKey(KeyCode.D))
- {
- this.transform.localScale = new Vector3(1, 1, 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement