V
V
VeoQlewer2018-09-27 20:16:27
Unity
VeoQlewer, 2018-09-27 20:16:27

Why can't I set localPosition?

After creating the object using the Instantiate method, I set its position:
Transform tBlocks = blocks.GetComponent();
tBlocks.localPosition = new Vector3(0f, -350f, 0f);
But X is shifted by some number. How to fix it?5bad1097c060e053113090.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2018-09-27
@VeoQlewer

The x isn't shifted anywhere, it's zero in exponential notation, it's just because of the transform hierarchy and other math noise that your float has slipped to the side by a very small value. The result is bitwise different from zero, but in fact it is still one. It may also be that this is a purely visual glitch of the RectTransform interface, after all, you didn’t change the anchoredPosition , but worked through the parent class, and that’s how it happened.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question