How to move a Child independently to another object and back.

How do I move a Child independently from it’s parent to another GameObject and then, after some amount of time, move it back the the position it was with it’s parent?

Hi,
There are two ways of doing that

1.By switching its parent back and forth

like the example here

public Transform Parent;

public float WaitTime = 2f;

float timeElapsed = 0f;
void Update()
{
 timeElapsed += Time.deltatime;
if(tiomeElapsed >= WaitTime)
{
transform.parent = Parent;
}else{
transform.parent = null;
}
}

2.To calculate the relative pos with respect to world

Whioch is quite difficult.In order to do that uo must calculate distance between parent and this object (at start Call it “dista” ) and then if the parent moves by a certain amount you place this object such that its position is dista times forawrd or backward dep[ending on parent position