Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Player : MonoBehaviour {
  5.  
  6.     public float velocidade;
  7.    
  8.     // Use this for initialization
  9.     void Start () {
  10.  
  11.     }
  12.  
  13.     // Update is called once per frame
  14.     void Update () {
  15.         Movimentacao();
  16.     }
  17.  
  18.     void Movimentacao() {
  19.  
  20.         if (Input.GetAxisRaw("Horizontal") > 0 )
  21.             transform.Translate (Vector2.right * velocidade * Time.deltaTime);
  22.         else if (Input.GetAxisRaw("Horizontal") < 0 )
  23.             transform.Translate (-Vector2.right * velocidade * Time.deltaTime);
  24.         else if (Input.GetAxisRaw("Vertical") > 0 )
  25.             transform.Translate (Vector2.up * velocidade * Time.deltaTime);
  26.         else if (Input.GetAxisRaw("Vertical") < 0 )
  27.             transform.Translate (-Vector2.up * velocidade * Time.deltaTime);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement