S
S
Sputnik Upitera2019-07-26 16:15:51
Unity
Sputnik Upitera, 2019-07-26 16:15:51

Is it possible to change the Transform of an object without changing the Transform of its child object?

When you change the Position and Rotation of an object, all of its child objects change these settings along with them. Is it possible to somehow force them to ignore these commands or even freeze them for a certain period of time (or forever)
Trying to do this, I just made the child object move and turn mirror to the parent. But the result did not satisfy me, because. the child object ends up moving down a bit .

el.transform.position += new Vector3(0.05f, 0, 0);
                el.transform.GetChild(0).transform.position += new Vector3(-0.05f, 0, 0);
                el.transform.rotation = Quaternion.Euler(0, 0, 10);
                el.transform.GetChild(0).transform.rotation = Quaternion.Euler(0, 0, 0);

                yield return new WaitForSeconds(0.02f);
                el.transform.position += new Vector3(-0.05f, 0, 0);
                el.transform.GetChild(0).transform.position += new Vector3(0.05f, 0, 0);
                el.transform.rotation = Quaternion.Euler(0, 0, -10);
                el.transform.GetChild(0).transform.rotation = Quaternion.Euler(0, 0, 0);

                yield return new WaitForSeconds(0.02f);
                el.transform.position += new Vector3(0.05f, 0, 0);
                el.transform.GetChild(0).transform.position += new Vector3(-0.05f, 0, 0);
                el.transform.rotation = Quaternion.Euler(0, 0, 10);
                el.transform.GetChild(0).transform.rotation = Quaternion.Euler(0, 0, 0);

                yield return new WaitForSeconds(0.02f);
                el.transform.position += new Vector3(-0.05f, 0, 0);
                el.transform.GetChild(0).transform.position += new Vector3(0.05f, 0, 0);
                el.transform.rotation = Quaternion.Euler(0, 0, 0);
                el.transform.GetChild(0).transform.rotation = Quaternion.Euler(0, 0, 0);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2019-07-26
@GavriKos

If you need to do this, then you have problems with the hierarchy.
And in general - LOCAL coordinates of children do not change. And the fact that it has moved globally - well, common, that's why the hierarchy is needed)
But in fact - either you do as freeExec said , or you apply a reverse transformation to the child (movement / rotation / scale in the other direction by the same amount).

F
freeExec, 2019-07-26
@freeExec

1) Remember the world coordinates of child objects;
2) You move the parent
3) You expose the saved coordinates to child objects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question