B
B
Boris192018-03-28 18:47:59
Unity
Boris19, 2018-03-28 18:47:59

Object position in Unity3D?

Added a parent 2D object, added a child 2D object to it. Now I want to output the position of the child ( x and y). In the inspector it shows (0,0) - this is correct, because I attached the child object to the top left corner of the parent. When I call Transform.position on this object in the script, it outputs (0, 10). This is a fig with him, it’s clear that this is a position in World coordinates, but why when I call Transform.localPosition, it displays again not (0, 0), but also (0, 10)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2018-03-28
@Boris19

For position relative to the anchor, you need to use RectTransform.anchoredPosition .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question