- Home /
Question by
Uniqeum · Mar 15, 2021 at 01:25 AM ·
transform.position
transform position not working (always in the center)
I use to set position of the object (the image attached to the object), but it appears in the center of the screen, not in the aim coordinates.
//newObject.GetComponent().anchoredPosition = new Vector3(targetPosition.x, targetPosition.y, floatz);
//newObject.transform.localPosition = new Vector3(targetPosition.x, targetPosition.y, floatz); //newObject.transform.TransformPoint(new Vector3(targetPosition.x, targetPosition.y, floatz));
/rectTransform = newObject.AddComponent(); rectTransform.position = new Vector3(targetPosition.x, targetPosition.y, floatz);
transform.GetComponent().localPosition = new Vector3(targetPosition.x, targetPosition.y, floatz); image.transform.position = new Vector3(targetPosition.x, targetPosition.y, floatz); image.rectTransform.localPosition = new Vector3(targetPosition.x, targetPosition.y, floatz);/
//newObject.GetComponent<RectTransform>().transform.position = new Vector3(targetPosition.x, targetPosition.y, floatz);
//image.rectTransform.anchoredPosition = new Vector3(targetPosition.x, targetPosition.y, floatz); //newObject.GetComponent().localPosition = new Vector3(targetPosition.x, targetPosition.y, floatz);
None of the above ways work good - the image is always in the center of the screen (targetPosition isn't the center, to make this clear). How to make it right?
Comment
Your answer
Follow this Question
Related Questions
Help with inheritance to show GUI 1 Answer
unwanted movements when camera follows object 0 Answers
Why can't I get the transform from an instantiated object? 1 Answer
Get an Object to move to a Position for a Fixed time 2 Answers
How to teleport the player to the location of an instantiated projectile? 1 Answer