World = Local
Public Gameobject Mtarget; Public Gameobject Mpar; This note must be the first parent of the Mtarget object. Use the this for initialization void Start () { string tarstr = string. Format ("Mtarget local:{0},world:{1}", MTarget.transform.localPosition, mTarget.transform.position); String parstr = String. Format ("Mpar local:{0},world:{1}", MPar.transform.localPosition, mPar.transform.position); Debug.Log (TARSTR); Debug.Log (PARSTR); var t = mPar.transform.InverseTransformPoint (mTarget.transform.position); Debug.Log (t); }
Note: World coordinates go to local coordinates. It is important to note that the inversetransformpoint of the world coordinates to local coordinates calls the transform of the parent object. Even if you have the parent of the parent object, you can use the parent object only.
Local = World
Worldpos = Mpar.transformpoint (Localpos);
Unity local coordinates to world coordinates, world coordinates to local coordinates