Unity local coordinates to world coordinates, world coordinates to local coordinates

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.