Noticias

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

usar el scroll en una camara 2d

Iniciado por berserker, Octubre 31, 2015, 02:20:35 PM

Tema anterior - Siguiente tema
Octubre 31, 2015, 02:20:35 PM Ultima modificación: Octubre 31, 2015, 02:32:23 PM por berserker
Buenas a todos, lo único Que estoy buscando es Modificar este scrip Para Que en Lugar de usar W y S subir y bajar, quiero Poder Hacerlo Con La Ruleta del Centro del Ratón (scroll),por otro Lado  he  Definido las variables  de Velocidad ,pero aunque modifico los Valores  la velocidad se queda exactamente La Misma, la velocidad normal es muy lenta y la  Rápida muy rápida¿como puedo Modificarlo?. 

var mainSpeed : float = 100.0; //regular speed

var shiftAdd : float = 250000.0; //multiplied by how long shift is held.  Basically running

var maxShift : float = 1000000000.0; //Maximum speed when holdin gshift

var camSens : float = 0.25; //How sensitive it with mouse

 

private var totalRun : float  = 1.0;

 

function Start (){

        Cursor.visible = true;

}

 

function Update () {

 

        var f : float = 0.0;

        var p = GetBaseInput();

 

        if (Input.GetKey (KeyCode.LeftShift)){

 

                totalRun += Time.deltaTime;

                p  = p * totalRun * shiftAdd;

                p.x = Mathf.Clamp(p.x, -maxShift, maxShift);

                p.y = Mathf.Clamp(p.y, -maxShift, maxShift);

            

        }

       

 

        p = p * Time.deltaTime;

 

        if (Input.GetKey(KeyCode.Space)){

 

                f = transform.position.y;

                transform.Translate(p);

                transform.position.y = f;

        }

        else{

                transform.Translate( p);

        }

}

 

private function GetBaseInput() : Vector3 {

 

        var p_Velocity : Vector3;

 

        if (Input.GetKey (KeyCode.W)){

                p_Velocity += Vector3(0, 4 );

        }

 

        if (Input.GetKey (KeyCode.S)){

                p_Velocity += Vector3(0, -4 );

        }

 

 

 

        return p_Velocity;

}


Tienes que cambiar el input.getKey:
 if (Input.GetAxis("Mouse ScrollWheel") > 0)
 p_Velocity +=Vector3(0,4);
 else
 p_Velocity -=Vector3(0,-4);
 

pues no ha funcionado, se mueve solo y no hace caso a la rueda del ratón,pero gracias por tu ayuda mrpacogp

Noviembre 01, 2015, 09:33:24 PM #3 Ultima modificación: Noviembre 01, 2015, 09:39:53 PM por kantusalfa
  var p_Velocity : Vector3;
 
    if (Input.GetAxis("Mouse ScrollWheel")<0) 
    
      p_Velocity +=Vector3(0,-4);
   
    else 
   
     if (Input.GetAxis("Mouse ScrollWheel")>0) 
      p_Velocity +=Vector3(0,4);
 para la velocidad usa una escala del vector mas grande para aumentar el desplazamiento(0,40);(0,-40);


Etiquetas: