Noticias

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

invertir eje Y/vertical durante el juego

Iniciado por Abramelin, Diciembre 25, 2015, 09:48:22 PM

Tema anterior - Siguiente tema
Estoy intentando hacer una opcion para cambiar el eje Y durante el juego pero algo debe andar mal:
var flipY = true;
var textosi : GameObject;
var textono : GameObject;

function Start(){
textosi.SetActive(true);
    textono.SetActive(false);
    }

function Update() {
    var inputY = Input.GetAxis("Vertical") * (flipY ? -1 : 1);
   
    if(Input.GetButtonDown("accion")){
    if (flipY == true){
    flipY = false;
    inputY = -1;
    textono.SetActive(true);
    textosi.SetActive(false);
    }
    else{
    flipY = true;
    inputY = 1;
    textosi.SetActive(true);
    textono.SetActive(false);
    }
    }
}
los objetos que muestran los textos (Si y No) funcionan correctamente, el problema es que no me invierte el eje vertical. y este es el parametro que quiero modificar: 


en esta parte del codigo creo que deberias de ponelo a a true no false.
if(Input.GetButtonDown("accion")){
    if (flipY == true){
    flipY = false;
    inputY = -1;
    textono.SetActive(true);
    textosi.SetActive(false);
   
if(Input.GetButtonDown("accion")){
    if (flipY == true){
    flipY = true;
    inputY = -1;
    textono.SetActive(true);
    textosi.SetActive(false);
 

Lo he cambiado por probar pero no es de eso, lo que hace es: si pulsas el boton y esta invertido lo pone en no-ivertido, si lo pulsas estando en no-invertido lo pone en invertido... esta linea la añadi a posteriori, por probar, ya que se supone que con la variable flipY cambia el valor de "vertical"
inputY = -1;
de todas formas es que no reconoce la variable flipY como "vertical",  si alguien puede probarlo...

Diciembre 26, 2015, 12:12:24 AM #3 Ultima modificación: Diciembre 26, 2015, 12:17:04 AM por Braltor
lo que sucede es que como tienes la condicion cuando sueltes el boton el estado de flipY se volvera true, por eso no perdura la seleccion. necesitas algo asi
    if(Input.GetButtonDown("accion")){
        flipY = !flipY;
       
    if (flipY == true){
    inputY = -1;
    textono.SetActive(true);
    textosi.SetActive(false);
    }
    else{
    inputY = 1;
    textosi.SetActive(true);
    textono.SetActive(false);
    }}
 

pues he probado eso y sigo sin conseguirlo, he cambiado "Vertical" por "Mouse Y", que en realidad era el que queria invertir y lo estaba poniendo mal. El codigo completo quedaría asi:
var flipY = true;
var textosi : GameObject;
var textono : GameObject;

function Start(){
textosi.SetActive(true);
    textono.SetActive(false);
    }

function Update() {
    var inputY = Input.GetAxis("Mouse Y") * (flipY ? -1 : 1);
   
    if(Input.GetButtonDown("accion")){
    flipY = !flipY;
   
    if (flipY == true){
    inputY = -1;
   
    textono.SetActive(true);
    textosi.SetActive(false);
    }
    else{
    inputY = 1;
   
    textosi.SetActive(true);
    textono.SetActive(false);
    }
    }
}

no se que estoy haciendo mal, he estado leyendo sobre el asunto y me he encontrado con esto (que dice que no es posible...) :http://answers.unity3d.com/questions/36530/invert-mouse-y-in-input-manager-through-codescript.html" rel="external nofollow">http://answers.unity3d.com/questions/36530/invert-mouse-y-in-input-manager-through-codescript.htmly este otro (el metodo que estoy usando y que no consigo que funcione.):http://answers.unity3d.com/questions/602326/invert-y-axis-on-game-configuration-how-to.html" rel="external nofollow">http://answers.unity3d.com/questions/602326/invert-y-axis-on-game-configuration-how-to.htmla ver si alguien que haya implementado la opcion de invertir el eje Y de la cam me pudiera echar un cable...

Etiquetas: