This is the original position of the cube and its child object cone.
Now I have rotated the parent cube around 25 degrees wrt to the Y-axis
If we translate the cone 2 units back again, it's not in the original position
What formula do I need to apply to the cone while translating it back to bring it back to it's original position?
Code: The below code is a coroutine for translating the child object
IEnumerator MoveToNewPos()
{
Vector3 newPos += Quaternion.Euler(0, 0, 135) * Vector3.left * distance;
float t = 0;
float animTime = 30;
isMoving = true;
for (; Vector3.Distance(transform.position, newPos) > 0.001f; t += Time.deltaTime)
{
float p = t / animTime;
transform.position = Vector3.Lerp(transform.position, newPos, p);
yield return null;
}
isMoving = false;
}
localPosition
. \$\endgroup\$