Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Player : MonoBehaviour
  5. {
  6.  
  7. public float velocidade;
  8. public float forcaPulo;
  9. private bool estaNoChao;
  10. public Transform chaoVerificador;
  11.  
  12. // Use this for initialization
  13. void Start()
  14. {
  15.  
  16. }
  17.  
  18. // Update is called once per frame
  19. void Update()
  20. {
  21. Movimentacao();
  22. }
  23.  
  24. void Movimentacao()
  25. {
  26.  
  27. estaNoChao = Physics2D.Linecast(transform.position, chaoVerificador.position, 1 << LayerMask.NameToLayer("Piso"));
  28. if (Input.GetAxis("Horizontal") > 0)
  29. {
  30. transform.Translate(Vector2.right * velocidade * Time.deltaTime);
  31. transform.eulerAngles = new Vector2(0, 0);
  32. }
  33.  
  34. if (Input.GetAxis("Horizontal") < 0)
  35. {
  36. transform.Translate(Vector2.right * velocidade * Time.deltaTime);
  37. transform.eulerAngles = new Vector2(0, 180);
  38. }
  39.  
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement