Noticias

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

[Ayuda] Problema rotación mouse en diferentes calidades de juego

Iniciado por Null, Noviembre 12, 2016, 07:16:42 PM

Tema anterior - Siguiente tema
Hola 
 
Resulta que quise hacer una build de mi juego para probarlo ya en sí, a ver cómo se veían ciertas cosas y etc,

pero me di cuenta de que si pongo la calidad en "Fastest" o también en "Fast" el movimiento del ratón se vuelve muy, muy lento.

Tanto así que tienes que mover toda la mano por la mesa para tan si quiera rotar unos pocos grados.
 
Sin embargo, en todas las demás calidades el ratón se mueve correctamente.

No he tocado ninguna opción gráfica, todas están por defecto.
 
Aún así, revisándolas dentro de Unity en la ventana Quality, veo que tanto Fastest como Fast tienen vSync en Off, y todas las demás en On,

así que pensé que ese puede ser el problema.
 
 
 
Aparte de activar la vSync en ambas configuraciones gráficas... debe de haber otra cosa que pueda hacer...

Sería terrible si alguien lo quiere jugar sin vSync y el ratón es una roca.
 
El script de mi cámara, por si dudas:
 

using UnityEngine;
using System.Collections;
[DisallowMultipleComponent]
public class CameraController : MonoBehaviour {
    /* VARIABLES */
    private GameObject _player;
    private PlayerController _pc = null;
    private float _xSensitivity;
    private float _ySensitivity;
    private float _originalSensitivity = 100f;
    private float _normalSmooth = 4f;
    private float _midairSmooth = 30f;
    private float _xRot;
    private float _yRot;
    private float _currentXRot;
    private float _currentYRot;
    private float _xRotSpeed;
    private float _yRotSpeed;
    private bool _canMoveCamera = true;
    /* PROPIEDADES */
    public bool CanMoveCamera {
        get { return _canMoveCamera; }
        set { _canMoveCamera = value; }
    }
    /* SISTEMA */
    void Awake() {
        _player = GameObject.FindGameObjectWithTag("Player");
        _pc = _player.GetComponent<PlayerController>();
    }
    void Start() {
        _player = transform.parent.gameObject;
        _xSensitivity = _originalSensitivity;
        _ySensitivity = _originalSensitivity;
    }
    void Update() {
        MouseMovement();
    }
    /* MIS MÉTODOS */
    public void MouseMovement() {
        if (_canMoveCamera) {
            _xRot -= Input.GetAxis("Mouse Y") * _xSensitivity * Time.deltaTime;
            _yRot += Input.GetAxis("Mouse X") * _ySensitivity * Time.deltaTime;
            _xRot = Mathf.Clamp(_xRot, -70f, 70f);
            // Decrementa la sensibilidad y añade SmoothDamp cuando el player esté cayendo desde x altura.
            if (_pc.IsFalling && (_pc.HeightCounter > _pc.MinHeightCounter)) {
                XYSensitivitiesTo(95f, 95f, 5f);
                SmoothDampVelocityTo(_midairSmooth);
                SetRotations();
            } else { // SmoothDamp vuelve a la normalidad.
                SmoothDampVelocityTo(_normalSmooth);
                SetRotations();
            }
            // Decrementa la sensibilidad siempre que el player esté saltando pero aún no cayendo.
            if (_pc.IsJumping && !_pc.IsFalling) {
                XYSensitivitiesTo(50f, 50f, 10f);
            }
            // Resetea la sensibilidad siempre que el player toque suelo.
            if (_pc.CC.isGrounded) {
                _xSensitivity = _originalSensitivity;
                _ySensitivity = _originalSensitivity;
            }
            if (_pc.IsRunning) {
                _ySensitivity = 70f;
            }
        } else { // Sigue actualizando las rotaciones a pesar de que no pueda mover la cámara.
            _currentXRot = transform.eulerAngles.x;
            _currentYRot = transform.eulerAngles.y;
            _xRot = transform.eulerAngles.x;
            _yRot = transform.eulerAngles.y;
        }
    }
    private void SetRotations() {
        transform.rotation = Quaternion.Euler(_currentXRot, _currentYRot, 0f);
        _player.transform.rotation = Quaternion.Euler(0f, _currentYRot, 0f);
    }
    private void XYSensitivitiesTo(float ToXSensitivity, float ToYSensitivity, float lerpVelocity) {
        _xSensitivity = Mathf.Lerp(_xSensitivity, ToXSensitivity, lerpVelocity * Time.deltaTime);
        _ySensitivity = Mathf.Lerp(_ySensitivity, ToYSensitivity, lerpVelocity * Time.deltaTime);
    }
    private void SmoothDampVelocityTo(float smoothAmount) {
        _currentXRot = Mathf.SmoothDamp(_currentXRot, _xRot, ref _xRotSpeed, smoothAmount * Time.deltaTime);
        _currentYRot = Mathf.SmoothDamp(_currentYRot, _yRot, ref _yRotSpeed, smoothAmount * Time.deltaTime);
    }
}

 
 

Viendo el code por encima, me parece que el problema es el Math.Lerp y el SmoothDamp. estas usando con Time.deltaTime lo que hace un fix segun los FPS. puede ser por eso que al usar VSync (que consume muchos fps) la velocidad de mouse se decremente.
 
De todas formas no creo que este script sea eficiente, hay formas mas sencillas livianas y directas para mover una cam, un object o 'x'.
 
Un saludo amigo.

····>Desarrollando un videojuegos online-arcade para Android.


····>Programador en:C,C#,VB.net,PHP,HTML5,SQL,JS,Ruby.


····>Trabajando en: Desarrollo de paginas web y bushistudios.


                    ๑۩۞۩๑_(▀▄)KINGTRASE()_๑۩۞۩๑ 



Etiquetas: