void Update() { // switch perspectives bool?switchPerspective = Util.InputGetAxisDown("NonVR Switch Perspective"); if (switchPerspective != null) { if (switchPerspective == true) { ShowCharacterPerspective(currentPerspective.Next()); } else { ShowCharacterPerspective(currentPerspective.Previous()); } } // collect modifiers bool altHandControl = (Input.GetAxis("NonVR Modify Hand Control") > 0); bool altHandDirection = (Input.GetAxis("NonVR Modify Hand Direction") > 0); // rotate hacker camera if (!altHandControl && (currentPerspective == Perspective.Hacker || currentPerspective == Perspective.Both)) { float x = Input.GetAxis("Mouse X"); float y = Input.GetAxis("Mouse Y"); var angles = transform.localEulerAngles; angles.y += x * rotationSpeed * Time.deltaTime; angles.x -= y * rotationSpeed * Time.deltaTime; // prevent bottom-up camera if (angles.x < 200) { angles.x = Mathf.Min(angles.x, 89); // 0-90 } else { angles.x = Mathf.Max(angles.x, 271); // 270-360 } transform.localEulerAngles = angles; } // move hacker if (currentPerspective == Perspective.Hacker || currentPerspective == Perspective.Both) { float x = Input.GetAxis("Horizontal"); float y = Input.GetAxis("Vertical"); float hbs = blockSize / 2; Vector3 newPosition = transform.localPosition; newPosition += movementSpeed * transform.forward * Time.deltaTime * y; newPosition += movementSpeed * transform.right * Time.deltaTime * x; newPosition.x = Mathf.Clamp(newPosition.x, -hbs, hbs); newPosition.z = Mathf.Clamp(newPosition.z, -hbs, hbs); newPosition.y = transform.localPosition.y; transform.localPosition = newPosition; } // switch hacker hands bool?nextHand = Util.InputGetAxisDown("NonVR Switch Active Hand"); if (nextHand == true) { currentHand = HackerHand.Right; } if (nextHand == false) { currentHand = HackerHand.Left; } // move hacker hands left/right/up/down if (altHandControl && (currentPerspective == Perspective.Hacker || currentPerspective == Perspective.Both)) { float x = Input.GetAxis("Mouse X"); float y = Input.GetAxis("Mouse Y"); GameObject handGO = player.GetHandGO(currentHand); float oldDist = Vector3.Distance(handGO.transform.position, hackerCamera.transform.position); // move Vector3 newPosition = handGO.transform.position; Vector3 baseDirection = altHandDirection ? transform.forward : transform.up; newPosition += handMovementSpeed * baseDirection * Time.deltaTime * y; newPosition += handMovementSpeed * handGO.transform.right * Time.deltaTime * x; // only store, if weapon is still in sight Vector3 viewportPoint = hackerCamera.WorldToViewportPoint(newPosition); if (viewportPoint.x >= 0 && viewportPoint.x <= 1 && viewportPoint.y >= 0 && viewportPoint.y <= 1) { handGO.transform.position = newPosition; } // rotate away from camera to be able to aim handGO.transform.rotation = Quaternion.LookRotation(handGO.transform.position - hackerCamera.transform.position); handGO.transform.Rotate(-10, 0, 0); // to see shot lasers // force hand to stay in same distance if (!altHandDirection) { Vector3 direction = handGO.transform.position - hackerCamera.transform.position; Vector3 directionNorm = direction.normalized; directionNorm *= (oldDist - direction.magnitude); handGO.transform.position += directionNorm; } } // trigger input if (currentPerspective == Perspective.Hacker || currentPerspective == Perspective.Both) { Action <HackerHand, bool> setInputFunc; if (Input.GetKey(KeyCode.LeftShift)) { setInputFunc = player.SetGripDown; } else { setInputFunc = player.SetTriggerDown; } if (Input.GetButtonDown("Fire1")) { setInputFunc(HackerHand.Left, true); } if (Input.GetButtonUp("Fire1")) { setInputFunc(HackerHand.Left, false); } if (Input.GetButtonDown("Fire2")) { setInputFunc(HackerHand.Right, true); } if (Input.GetButtonUp("Fire2")) { setInputFunc(HackerHand.Right, false); } } // switch weapon if (currentPerspective == Perspective.Hacker || currentPerspective == Perspective.Both) { if (Input.GetButtonDown("Jump")) { StartCoroutine(SwitchWeapon(currentHand)); } } }