Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Player : MonoBehaviour {
- public float velocidade;
- public float forcaPulo;
- private bool estaNoChao;
- public Transform chaoVerificador;
- /********************* AQUI ***************************/
- private Rigidbody2D rigidbody2D;
- /********************* AQUI ***************************/
- // Use this for initialization
- void Start () {
- /********************* E AQUI ***************************/
- rigidbody2D = GetComponent<Rigidbody2D>();
- /********************* E AQUI ***************************/
- }
- // Update is called once per frame
- void Update () {
- Movimentacao();
- }
- void Movimentacao() {
- estaNoChao = Physics2D.Linecast(transform.position, chaoVerificador.position, 1 << LayerMask.NameToLayer("Piso"));
- if (Input.GetAxisRaw("Horizontal") > 0 ) {
- transform.Translate (Vector2.right * velocidade * Time.deltaTime);
- transform.eulerAngles = new Vector2(0, 0);
- }
- if (Input.GetAxisRaw("Horizontal") < 0 ) {
- transform.Translate (Vector2.right * velocidade * Time.deltaTime);
- transform.eulerAngles = new Vector2(0, 180);
- }
- if (Input.GetButtonDown("Jump") && estaNoChao) {
- rigidbody2D.AddForce(transform.up * forcaPulo);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement