Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MovimentoPlayer : MonoBehaviour {
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if(Input.GetKey(KeyCode.A))
- {
- this.transform.Translate(-5 * Time.deltaTime,0 ,0);
- }
- if(Input.GetKey (KeyCode.D))
- {
- this.transform.Translate (5 * Time.deltaTime, 0, 0);
- }
- if(Input.GetKey (KeyCode.W))
- {
- this.transform.Translate (0, 10 * Time.deltaTime, 0);
- }
- }
- void OnCollisionEnter2D(Collision2D colidir)
- {
- float posicaoInimigo = colidir.transform.position.y;
- float posicaoPlayer = transform.position.y;
- if (colidir.gameObject.tag == "Inimigo")
- {
- if(posicaoPlayer < posicaoInimigo)
- {
- print ("VENCEU!!!!");
- }
- else
- {
- print ("morreu, posiçao do pulo inimigo: " + posicaoInimigo + " --- Posiçao do player: " + posicaoPlayer);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement