I’ve a semicircle like sport object which I made by placing two arcs in an empty sport object (SCircle) and rotating the 15° (for left arc) and -15° (for proper arc) as seen under.
SCircle
has an Orientation
enum with two valuesLeft
(rotates SCircle to 45°) and Proper
(rotates SCircle
to -45°) as seen within the picture under.
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 under:
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 be run. On this case the arcs find yourself shifting from Left
to A, which isn’t the conduct I would like. I’d need the conduct 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 be aware that the blue arrow represents the motion of the left Arc, the pink represents the correct Arc and the black represents motion of SCircle
– the mother or father object.
How can I obtain the conduct from Left to B and from B again to Left?