i have create animation using position and rotation using but I cant use it any where else ,
for example I want to rotate(play-animation)[https://youtu.be/lfITV70czsc] 120deg left or right according to users input(left,right button) in different locations
is there anything can do to achieve this I tried scripting but it doesn’t seem working
private IEnumerator SwipeLeftRight(float angle)
{
if (isRotating) yield break; // Prevent starting another rotation while one is ongoing
isRotating = true;
float elapsed = 0f;
float duration = 0.3f;
float startAngle = 0f;
float endAngle = angle;
while (elapsed < duration)
{
elapsed += Time.deltaTime;
float currentAngle = Mathf.Lerp(startAngle, endAngle, elapsed / duration);
float deltaAngle = currentAngle - transform.eulerAngles.y; // Calculate incremental rotation
transform.RotateAround(pivitCylinder.transform.position, Vector3.up, deltaAngle);
Debug.Log(deltaAngle+"delta");
Debug.Log(currentAngle+"cureeebt");
yield return null;
}
// Ensure it ends exactly at the target angle
transform.RotateAround(pivitCylinder.transform.position, Vector3.up, angle - transform.eulerAngles.y);
isRotating = false;
}