I’ve an object of the semicircle sport that I made by putting two arches in an empty sport object (Scircle) and turning the 15 ° (for the left arch) and -15 ° (for the correct arch) as seen under.
SCircle
It has a Orientation
Enum with two valuesLeft
(Flip the circle at 45 °) and Proper
(tour SCircle
at -45 °) as seen within the picture under.
I take advantage of the next choroutine to maneuver SCircle
Between orientations.
IEnumerator RotateLeftOrRight(Vector3 byAngles, float inTime)
{
Quaternion fromAngle = gameObject.rework.rotation ;
Quaternion toAngle = Quaternion.Euler (rework.eulerAngles);
if (circOrientation == Orientation.Left) {
toAngle = Quaternion.Euler (gameObject.rework.eulerAngles - byAngles);
circOrientation = Orientation.Proper;
}
else if (circOrientation == Orientation.Proper) {
toAngle = Quaternion.Euler (gameObject.rework.eulerAngles + byAngles);
circOrientation = Orientation.Left;
}
for(float t = 0f ; t <= 1f ; t += Time.deltaTime/inTime)
{
gameObject.rework.rotation = Quaternion.Lerp(fromAngle, toAngle, t) ;
yield return null ;
gameObject.rework.rotation = Quaternion.Lerp(fromAngle, toAngle, 1);
}
}
I additionally used a really comparable choroutine to maneuver particular person arches by 30 ° (in reverse instructions) from, for instance, orientation Left
as seen under:
From SCircle
The choroutine is activated by a mouse click on, I’ve the case wherein the person arc chorout is executed and earlier than finishing the daddy SCircle
Coroutine can also be executed. On this case, the arches find yourself shifting from Left
A, which isn’t the habits I want. I would love the habits to finish in B after they transfer from Left
. In the identical approach, of B, when the SCircle
Coroutine runs because the Arcs Coroutine is in progress, the orientation will return to the Left
.
Word that the blue arrow represents the motion of the left arch, the pink represents the correct arc and the black represents the motion of SCircle
– The principle object.
How can I obtain the habits of the left A B and B from return to the left?