public void Update() { if (Application.isPlaying == true && GUIUtility.hotControl == 0) { if (SGT_Input.GetKey((KeyCode)rotationRequires, 1) == true) { var x = SGT_Input.DragY * -rotationSpeed; var y = SGT_Input.DragX * rotationSpeed; targetRotation *= Quaternion.Euler(x, y, 0.0f); } } var currentRotation = transform.localRotation; if (Application.isPlaying == true) { var dampenFactor = SGT_Helper.DampenFactor(rotationDampening, Time.deltaTime); currentRotation = Quaternion.Slerp(currentRotation, targetRotation, dampenFactor); } else { currentRotation = targetRotation; } SGT_Helper.SetLocalRotation(transform, currentRotation); }
public void Update() { if (Application.isPlaying == true && GUIUtility.hotControl == 0) { if (Input.GetKey(KeyCode.Mouse0) == true) { var x = SGT_Input.DragY * -rotationSpeed; var y = SGT_Input.DragX * rotationSpeed; targetRotation *= Quaternion.Euler(x, y, 0.0f); } if (rotationRoll == true) { if (Input.GetKey(KeyCode.Mouse1) == true) { var z = SGT_Input.DragRoll; targetRotation *= Quaternion.Euler(0.0f, 0.0f, z); } } targetDistance -= SGT_Input.Zoom * (1.0f + targetDistance - distanceMin) * distanceSpeed; } targetDistance = Mathf.Clamp(targetDistance, distanceMin, distanceMax); var currentDistance = transform.localPosition.magnitude; var currentRotation = transform.localRotation; if (Application.isPlaying == true) { var rotationDampenFactor = SGT_Helper.DampenFactor(rotationDampening, Time.deltaTime); var distanceDampenFactor = SGT_Helper.DampenFactor(distanceDampening, Time.deltaTime); currentRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationDampenFactor); currentDistance = Mathf.Lerp(currentDistance, targetDistance, distanceDampenFactor); } else { currentRotation = targetRotation; currentDistance = targetDistance; } SGT_Helper.SetLocalRotation(transform, currentRotation); SGT_Helper.SetLocalPosition(transform, currentRotation * new Vector3(0.0f, 0.0f, -currentDistance)); }
public void Update() { if (Application.isPlaying == true) { SGT_Helper.BeginRandomSeed(seed); { if (rotation == true) { rotationChangeTime -= Time.deltaTime; if (rotationChangeTime <= 0.0f) { rotationChangeTime = rotationChangeDelay; targetBearing = Random.Range(-1.0f, 1.0f); } var dampenFactor = SGT_Helper.DampenFactor(rotationDampening, Time.deltaTime); currentBearing = Mathf.Lerp(currentBearing, targetBearing, dampenFactor); var dps = SGT_Helper.DegreesPerSecond(rotationPeriod); transform.localRotation *= Quaternion.Euler(dps * currentBearing * Time.deltaTime, dps * Time.deltaTime, 0.0f); } if (scale == true) { scaleChangeTime -= Time.deltaTime; if (scaleChangeTime <= 0.0f) { scaleChangeTime = scaleChangeDelay; targetScale = Random.Range(scaleMin, scaleMax); } var dampenFactor = SGT_Helper.DampenFactor(scaleDampening, Time.deltaTime); var newScale = Mathf.Lerp(UniformScale, targetScale, dampenFactor); transform.localScale = new Vector3(newScale, newScale, newScale); } } seed = SGT_Helper.EndRandomSeed(); } }