private IEnumerator ForceHeldRotation(bool frontFace, float duration) { Transform baseTransform = SelectableManager.GetBaseHeldObjectTransform(); float oldZSpin = _heldFrontFace ? 0.0f : 180.0f; float targetZSpin = frontFace ? 0.0f : 180.0f; float initialTime = Time.time; while (Time.time - initialTime < duration) { float lerp = (Time.time - initialTime) / duration; float currentZSpin = Mathf.SmoothStep(oldZSpin, targetZSpin, lerp); Quaternion currentRotation = Quaternion.Euler(0.0f, 0.0f, currentZSpin); SelectableManager.SetZSpin(currentZSpin); SelectableManager.SetControlsRotation(baseTransform.rotation * currentRotation); SelectableManager.HandleFaceSelection(); yield return(null); } SelectableManager.SetZSpin(targetZSpin); SelectableManager.SetControlsRotation(baseTransform.rotation * Quaternion.Euler(0.0f, 0.0f, targetZSpin)); SelectableManager.HandleFaceSelection(); _heldFrontFace = frontFace; }
public void RotateByLocalQuaternion(Quaternion localQuaternion) { Transform baseTransform = SelectableManager.GetBaseHeldObjectTransform(); float currentZSpin = _heldFrontFace ? 0.0f : 180.0f; SelectableManager.SetControlsRotation(baseTransform.rotation * Quaternion.Euler(0.0f, 0.0f, currentZSpin) * localQuaternion); SelectableManager.HandleFaceSelection(); }
private IEnumerator ForceHeldRotation(float duration) { Transform baseTransform = SelectableManager.GetBaseHeldObjectTransform(); float initialTime = Time.time; while (Time.time - initialTime < duration) { Quaternion currentRotation = Quaternion.Euler(0.0f, 0.0f, 0.0f); SelectableManager.SetZSpin(0.0f); SelectableManager.SetControlsRotation(baseTransform.rotation * currentRotation); SelectableManager.HandleFaceSelection(); yield return(null); } SelectableManager.SetZSpin(0.0f); SelectableManager.SetControlsRotation(baseTransform.rotation * Quaternion.Euler(0.0f, 0.0f, 0.0f)); SelectableManager.HandleFaceSelection(); }
private IEnumerator ForceHeldRotation(bool frontFace, float duration) { SelectableManager selectableManager = KTInputManager.Instance.SelectableManager; Transform baseTransform = selectableManager.GetBaseHeldObjectTransform(); float oldZSpin = selectableManager.GetZSpin(); float targetZSpin = frontFace ? 0.0f : 180.0f; float initialTime = Time.time; while (Time.time - initialTime < duration) { float lerp = (Time.time - initialTime) / duration; float currentZSpin = Mathf.SmoothStep(oldZSpin, targetZSpin, lerp); Quaternion currentRotation = Quaternion.Euler(0.0f, 0.0f, currentZSpin); Vector3 HeldObjectTiltEulerAngles = selectableManager.GetHeldObjectTiltEulerAngles(); HeldObjectTiltEulerAngles.x = Mathf.Clamp(HeldObjectTiltEulerAngles.x, -95f, 95f); HeldObjectTiltEulerAngles.z -= selectableManager.GetZSpin() - currentZSpin; selectableManager.SetZSpin(currentZSpin); selectableManager.SetControlsRotation(baseTransform.rotation * currentRotation); selectableManager.SetHeldObjectTiltEulerAngles(HeldObjectTiltEulerAngles); selectableManager.HandleFaceSelection(); yield return(null); } Vector3 HeldObjectTileEulerAnglesFinal = selectableManager.GetHeldObjectTiltEulerAngles(); HeldObjectTileEulerAnglesFinal.x = Mathf.Clamp(HeldObjectTileEulerAnglesFinal.x, -95f, 95f); HeldObjectTileEulerAnglesFinal.z -= selectableManager.GetZSpin() - targetZSpin; selectableManager.SetZSpin(targetZSpin); selectableManager.SetControlsRotation(baseTransform.rotation * Quaternion.Euler(0.0f, 0.0f, targetZSpin)); selectableManager.SetHeldObjectTiltEulerAngles(HeldObjectTileEulerAnglesFinal); selectableManager.HandleFaceSelection(); }