Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Even though both are at position (0,0,0), two game objects are not centered around same point.

Discussion in '2D' started by southperry, Jul 27, 2022.

  1. southperry

    southperry

    Joined:
    Jul 22, 2022
    Posts:
    4
    Hi all, I'm new to Unity and working on my first small project. I have a 5x5 grid of square game objects, the center one positioned at 0,0,0. The camera is also at (0,0,0). However, other game objects I create and include such as background, etc., don't center at the same position as that initial square. It can be seen in these screenshots - see the gaps on either side of the squares to the camera. Any idea as to why this is?

    Thank you for any recommendations! Screenshot 2022-07-26 203253.png Screenshot 2022-07-26 203326.png
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    530
    Position of object is relative to parent in the object hierarchy. That's the whole point of object hierarchy. You might want to read https://docs.unity3d.com/Manual/class-Transform.html to better understand basics of transforms in Unity.

    In your example check the position of Rooms object. It is likely at position 10.

    As a general advice pay attention to image pivots as those also affect how objects are centered (probably not the problem in your current situation).
     
    LeoKolaMax and southperry like this.
  3. southperry

    southperry

    Joined:
    Jul 22, 2022
    Posts:
    4
    You were exactly right - the Rooms object was not properly centered! Thank you for sharing that transform documentation - I'm definitely still trying to wrap my head around all the basics, and this was one of those spots where a gap in my basic Unity knowledge turned a simple problem into one I really struggled with. Thanks!