// Update is called once per frame void Update() { arm = Input.GetAxis("Arm"); if (xInput.IsWorking()) { arm = xInput.GetAxis("Arm"); } transform.Rotate(new Vector3(0f, 0f, armSpeed * arm * Time.deltaTime)); if (transform.localRotation.eulerAngles.z > 180) { transform.localRotation = Quaternion.Euler( transform.localRotation.eulerAngles.x, transform.localRotation.eulerAngles.y, Mathf.Clamp(transform.localRotation.eulerAngles.z, leftLimit, 360f)); } if (transform.localRotation.eulerAngles.z < 180 && transform.localRotation.eulerAngles.z > 0) { transform.localRotation = Quaternion.Euler( transform.localRotation.eulerAngles.x, transform.localRotation.eulerAngles.y, Mathf.Clamp(transform.localRotation.eulerAngles.z, 0f, rightLimit)); } // traansform.localRotation = Quaternion.Euler ( // transform.localRotation.eulerAngles.x, // transform.localRotation.eulerAngles.y, // Mathf.Clamp (transform.localRotation.eulerAngles.z, rightLimit, leftLimit)); angle = transform.localRotation.eulerAngles; }
// Update is called once per frame void Update() { float vertical = Input.GetAxis("Vertical"); float horizontal = Input.GetAxis("Horizontal"); float rotate = Input.GetAxis("Rotate"); if (xInput.IsWorking()) { vertical = xInput.GetAxis("Vertical"); horizontal = xInput.GetAxis("Horizontal"); rotate = xInput.GetAxis("Rotate"); } drive.frontRight.motorValue = 127f * (vertical - rotate - horizontal); drive.frontLeft.motorValue = 127f * (vertical + rotate + horizontal); drive.backRight.motorValue = -127f * (vertical - rotate + horizontal); drive.backLeft.motorValue = -127f * (vertical + rotate - horizontal); angularVelocity = angularSpeed * rotate; }
void Update() { float lift = Input.GetAxis("Lift"); if (xInput.IsWorking()) { lift = xInput.GetAxis("Lift"); } float deltaHeight = (lift > 0)? maxLiftSpeed * lift * Time.deltaTime : maxLowerSpeed * lift * Time.deltaTime; float stageDeltaHeight = 0f; for (int i = 0; i < numStages; i++) { stageDeltaHeight = Mathf.Clamp(stageHeights[i] + deltaHeight, 0, maxHeightsPerStage[i]) - stageHeights[i]; deltaHeight -= stageDeltaHeight; stageHeights[i] += stageDeltaHeight; stages[i].position += new Vector3(0, stageDeltaHeight, 0); } }
private float GetAxis(AxisSet.AxisCascade axisCascade) { float value = 0; try { value += UnityEngine.Input.GetAxis(axisCascade.pcName); } catch (System.Exception) { try { value += UnityEngine.Input.GetButton(axisCascade.pcName) ? 1 : 0; } catch (System.Exception) { } } value += XboxInput.GetAxis(_inputId, axisCascade.xboxAxis); value += UIInput.GetAxis(axisCascade.uIAxis); return(Mathf.Clamp(value, -1, 1)); }