Unity Spain

Post Antiguos => General (Antiguo) => Mensaje iniciado por: Alanc89 en Octubre 27, 2015, 07:58:43 PM

Título: Aporte de codigo voltear y mover sprite IZQ DER + Duda
Publicado por: Alanc89 en Octubre 27, 2015, 07:58:43 PM
using UnityEngine;
using System.Collections;

public class Personaje : MonoBehaviour {

public KeyCode right;
public KeyCode left;
public KeyCode up;

private int MirarIZQ = -1;
private int MirarDER = 1;


void FixedUpdate ()
{
   if (Input.GetKey(right))
   {
      VolteaDER ();
      transform.Translate(new Vector2(0.1f, 0.0f));
   }
   if (Input.GetKey(left))
   {
      VolteaIZQ ();
      transform.Translate(new Vector2(-0.1f, 0.0f));
   }
   if (Input.GetKey(up))
   {
      transform.Translate(new Vector2(0.0f,0.1f));
   }
}

void VolteaIZQ ()
{
   transform.localScale = new Vector3(MirarIZQ, 1, 1);
}

void VolteaDER ()
{
   transform.localScale = new Vector3(MirarDER, 1, 1);
}


}
El código funciona ok, pero quiero añadirle el movimiento de mi personaje cuando camina, ya tengo hecha las transiciones y animaciones (es un sprite), (idle, run, air), air = saltar). Intente de todo pero no puedo lograrlo.