Set child position and move parents with

I’m creating a game and I have a problem.
I have a gameObject with a rigidbody and some script. This gameObject has 2 child and each child has a collider (trigger).
In a script I need to set the position and the rotation of the child and I want that the parent come with the child so the global structure stay the same.
I tried with a the localPosition but nothing work.
Do you get any idea?

Moving or rotating a parent object and its children should be done by transforming the parent. All child objects will automatically transform with the parent. What this means is that you should consider trying to use the parent to move your game object rather than moving the children and then mathematically calculating where the parent should be. You can think of the children as being anchored to the parent, and anything the parent does, its children will do also. This does not work the other way around.

Also, make sure that you are changing the parent’s rotation/position correctly in your scripts. Don’t do this:

var position = parentTransform.position; // This is a copy of the parent's position
var otherPosition = new Vector(1.0f, 2.0f, 3.0f);
position = position - otherPosition; // Will not change the transform of the parent object

In order to actually set the position, you must instead do:

var otherPosition = new Vector(1.0f, 2.0f, 3.0f);
// Will correctly change the transform
parentTransform.position = parentTransform.position - otherPosition; 

Make sure you are setting the position or rotation directly from the object. Don’t store it in a variable and expect it to actually transform the game object. Hope this helped.

I don’t know if i’m getting it right, but i think you can invert the parent order.

So it would be something like:
When you are moving the parent from the child.
transform.SetParent(childTransform, true);

When you want to reverse to originalState:

Didn’t test it.