I’ve a semicircle like recreation object which I made by placing two arcs in an empty recreation object (SCircle) and rotating the 15° (for left arc) and -15° (for proper arc) as seen beneath.
SCircle
has an Orientation
enum with two valuesLeft
(rotates SCircle to 45°) and Proper
(rotates SCircle
to -45°) as seen within the picture beneath.
I exploit the next coroutine to maneuver SCircle
between orientations.
IEnumerator RotateLeftOrRight(Vector3 byAngles, float inTime)
{
Quaternion fromAngle = gameObject.remodel.rotation ;
Quaternion toAngle = Quaternion.Euler (remodel.eulerAngles);
if (circOrientation == Orientation.Left) {
toAngle = Quaternion.Euler (gameObject.remodel.eulerAngles - byAngles);
circOrientation = Orientation.Proper;
}
else if (circOrientation == Orientation.Proper) {
toAngle = Quaternion.Euler (gameObject.remodel.eulerAngles + byAngles);
circOrientation = Orientation.Left;
}
for(float t = 0f ; t <= 1f ; t += Time.deltaTime/inTime)
{
gameObject.remodel.rotation = Quaternion.Lerp(fromAngle, toAngle, t) ;
yield return null ;
gameObject.remodel.rotation = Quaternion.Lerp(fromAngle, toAngle, 1);
}
}
I additionally used a really comparable coroutine to maneuver the person arcs by 30° (in reverse instructions) from say, Orientation Left
, as seen beneath:
Since SCircle
Coroutine is activated by a mouse click on, I’ve the case the place the person arcs coroutine is run and earlier than it’s full the mother or father SCircle
coroutine can also be run. On this case the arcs find yourself shifting from Left
to A, which isn’t the habits I would like. I might need the habits of them ending up at B when shifting from the Left
. Likewise, from B, when the SCircle
coroutine is run whereas the arcs coroutine is in progress the orientation will return to the Left
.
Please notice that the blue arrow represents the motion of the left Arc, the crimson represents the best Arc and the black represents motion of SCircle
– the mother or father object.
How can I obtain the habits from Left to B and from B again to Left?