Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Let us know your feedback about the Global Illumination changes in the 2023.2 beta.
    Dismiss Notice
  3. Dismiss Notice

mouse slow in webgl

Discussion in 'Unity 5 Pre-order Beta' started by kryptopath2, Nov 19, 2014.

  1. kryptopath2

    kryptopath2

    Joined:
    Jul 19, 2013
    Posts:
    104
    hi,
    i have a simple scene with mouse orbit. in the editor the speed of the mouse is good, in the webgl-built it is a looot slower. did i miss some settings?
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Did you multiply the input with Time.deltaTime to make it independent of the framerate?
     
  3. kryptopath2

    kryptopath2

    Joined:
    Jul 19, 2013
    Posts:
    104
    ah, i knew something like this would happen :D i am no programmer, not even close to one.. where do i have to do this?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Do not multiply mouse input by Time.deltaTime...mouse input is already framerate-independent, so using Time.deltaTime in this context is exactly the opposite of what you want (it makes movement dependent on framerate).

    --Eric
     
  5. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Oh my, Eric is certainly right.
     
  6. kryptopath2

    kryptopath2

    Joined:
    Jul 19, 2013
    Posts:
    104
    so, now i know what i shouldn't do ;)
    any solution?
     
  7. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You should show your orbit code, because we don't know what exactly you are doing.
     
  8. kryptopath2

    kryptopath2

    Joined:
    Jul 19, 2013
    Posts:
    104
    it is the script that comes with unity. i didn't write anything myself.

    var target : Transform;
    var distance = 10.0;

    var xSpeed = 250.0;
    var ySpeed = 120.0;

    var yMinLimit = -20;
    var yMaxLimit = 80;

    private var x = 0.0;
    private var y = 0.0;

    @script AddComponentMenu("Camera-Control/Mouse Orbit")

    function Start () {
    var angles = transform.eulerAngles;
    x = angles.y;
    y = angles.x;

    // Make the rigid body not change rotation
    if (GetComponent.<Rigidbody>())
    GetComponent.<Rigidbody>().freezeRotation = true;
    }

    function LateUpdate () {
    if (target && Input.GetMouseButton(0)) {
    x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
    y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;

    y = ClampAngle(y, yMinLimit, yMaxLimit);

    var rotation = Quaternion.Euler(y, x, 0);
    var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;

    transform.rotation = rotation;
    transform.position = position;
    }
    }

    static function ClampAngle (angle : float, min : float, max : float) {
    if (angle < -360)
    angle += 360;
    if (angle > 360)
    angle -= 360;
    return Mathf.Clamp (angle, min, max);
    }
     
    Last edited: Nov 20, 2014
  9. aiab_animech

    aiab_animech

    Joined:
    Jul 4, 2012
    Posts:
    177
    I have the same problem. Factor 8 to 10 in difference.
     
  10. kryptopath2

    kryptopath2

    Joined:
    Jul 19, 2013
    Posts:
    104
    should i report it as a bug?
     
  11. kryptopath2

    kryptopath2

    Joined:
    Jul 19, 2013
    Posts:
    104
    still the same problem (beta18). another scene and the standard fps-controller. looking aroudn with the mouse is very slow. in the editor it is ok, in the webgl-built it is around half the speed..

    (firefox and chrome)
     
    Last edited: Dec 26, 2014