- Home /
Question by
Kalata8662 · Apr 09, 2017 at 05:31 AM ·
scripting problembugwebgl
Web GL and Unity editor defferent behaviour
Hi, I'm trying to create a script that moves the camera around with the mouse scroll and can also rotate the camera around. This is my code:
void LateUpdate () {
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
RotationX = RotationX + Input.GetAxis ("Mouse X")*MouseAcc*Time.deltaTime;
RotationY = RotationY - Input.GetAxis ("Mouse Y")*MouseAcc*Time.deltaTime;
transform.rotation = Quaternion.Euler (RotationY, RotationX, 0);
if (Input.mouseScrollDelta.y != 0) {
T = 0;
DirTo = transform.forward;
Dir = Input.mouseScrollDelta.y / Mathf.Abs (Input.mouseScrollDelta.y);
StopAllCoroutines ();
MoveCoroutine = StartCoroutine (MoveAbit());
}
chc.Move (Velocity * WalkSpeed * Time.deltaTime);
}
IEnumerator MoveAbit() {
while (T < 0.3f) {
Velocity = DirTo.normalized* Mathf.Clamp (Dir, -1, 1);
T+=Time.deltaTime;
yield return new WaitForSeconds (Time.deltaTime);
}
Velocity = Vector3.zero;
}
This code works exactly like I want it to work in the editor - you can rotate and move with the mouse wheel. When I run the WebGL on Google Chrome though, the camera strangely changes it's rotation instantly after the scroll movement stops. It's like instantly adding 90 degree rotation. I have tried to find what's causing it with no luck Any help will be apreciated, thank you!
Comment