Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Aporte de codigo voltear y mover sprite IZQ DER + Duda

Iniciado por Alanc89, Octubre 27, 2015, 07:58:43 PM

Tema anterior - Siguiente tema
Octubre 27, 2015, 07:58:43 PM Ultima modificación: Enero 01, 1970, 01:00:00 AM por Alanc89
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.

Etiquetas: