private bool TryRotateUsingStarter(GameObject shipBase) { float rotationFix = TryGetRotationFixFinisher(shipBase); bool result = false; if (!float.IsNaN(rotationFix)) { result = true; float angleFix = GetAngleFixRotation(shipBase); float savedRotation = TheShip.GetModelOrientation().transform.localEulerAngles.y; TheShip.SetRotationHelper2Angles(new Vector3(0, rotationFix, 0)); TheShip.UpdateRotationHelperAngles(new Vector3(0, angleFix, 0)); if (GetPathToProcessLeft(shipBase) <= 0) { result = false; TheShip.SetRotationHelper2Angles(new Vector3(0, savedRotation, 0)); TheShip.UpdateRotationHelperAngles(new Vector3(0, -angleFix, 0)); } } return(result); }
// ROTATION public void UpdateRotation() { if (GetPathToProcessLeft(TheShip.GetModelOrientation()) > 0) { float rotationFix = GetRotationFix(TheShip.GetModelOrientation()); TheShip.SetRotationHelper2Angles(new Vector3(0, rotationFix, 0)); float angleFix = GetAngleFix(TheShip.GetModelOrientation()); TheShip.UpdateRotationHelperAngles(new Vector3(0, angleFix, 0)); } AddMovementTemplateCenterPoint(TheShip.Model); }
public void UpdateRotationFinisher() { if (MovementTemplates.CurrentTemplate.transform.Find("Finisher") != null) { TheShip.SimplifyRotationHelpers(); bool isSuccessfull = TryRotateUsingStarter(TheShip.GetModelOrientation()); //bool isSuccessfull = false; if (!isSuccessfull) { if (GetPathToProcessFinisherLeft(TheShip.Model) > 0) { float angleToNearestCenterPoint = GetAngleToLastSavedTemplateCenterPoint(TheShip.GetModelOrientation()); TheShip.UpdateRotationHelper2Angles(new Vector3(0, angleToNearestCenterPoint * GetDirectionModifier(), 0)); } } } }