void Update() { if (before) { application?.Update(); } lastMouse = Input.mousePosition - lastMouse; lastMouse = new Vector3(-lastMouse.y * camSens, lastMouse.x * camSens, 0); lastMouse = new Vector3(transform.eulerAngles.x + lastMouse.x, transform.eulerAngles.y + lastMouse.y, 0); transform.eulerAngles = lastMouse; lastMouse = Input.mousePosition; //Mouse camera angle done. //Keyboard commands Vector3 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.z = Mathf.Clamp(p.z, -maxShift, maxShift); } else { totalRun = Mathf.Clamp(totalRun * 0.5f, 1f, 1000f); p = p * mainSpeed; } p = p * Time.deltaTime; Vector3 newPosition = transform.position; if (Input.GetKey(KeyCode.Space)) { //If player wants to move on X and Z axis only transform.Translate(p); newPosition.x = transform.position.x; newPosition.z = transform.position.z; transform.position = newPosition; } else { transform.Translate(p); } if (!before) { application?.Update(); } }
private void Update() { if (type == null) { return; } application?.Update(); application?.GetView(0).SetSize((int)application.Width, (int)application.Height); }