Search Unity

The gizmo and gameobject dont have the same possition.

Discussion in 'Editor & General Support' started by PetterL68, Sep 20, 2018.

  1. PetterL68

    PetterL68

    Joined:
    Jun 26, 2018
    Posts:
    23
    Hi.
    Im pretty new to Unity and following a online course.
    But yesterday i got a real strange problem with one of my prefab that i have made in the course.
    The gameobject and the Gizmo dont have the same position, making any new prefab a hell to place.

    I have tried to delete all copies of the Prefab and tried again but same appear. Others is OK.
    Thinking about deleting the prefab and start all over. But is it some easier way to fix it ?
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    The quick answer you are looking for is that you want to use transform.position for your Gizmos position, and not transform.localPosition. (Or maybe the opposite, it's hard to tell if you're trying to position things based on the prefab or the world around the prefab)

    There are 2 types of positions: local position and world position. When you put one object "inside" another object in the hierarchy window, you have a parent object and child object. When an object has a parent, it's local position is now relative to it's parent, which means local position (0, 0, 0) for the child object is the world position of the parent object, even if that position is not (0, 0, 0).

    If you give an object a new parent without moving the object, it's local position will change based on the new parent's position, but it's world position will not change. If an object has no parent, it's local position is it's world position.
     
    Last edited: Sep 20, 2018
  3. PetterL68

    PetterL68

    Joined:
    Jun 26, 2018
    Posts:
    23
    Thanks for the reply
    I IMG_20180920_203759.jpg have taken a picture of the screen.

    Here is the Coin. The yellow dot on the left hand and the box and the sphere on the way to the gamescreen
     
  4. PetterL68

    PetterL68

    Joined:
    Jun 26, 2018
    Posts:
    23
    I think i solved it in some way. I copied the prefab file and meta from the folder and deleted it there and in the scene. /prefab folder. Imported it again and tt started to behave normally again.
     
  5. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    If you're talking about the handles (the 3 colored arrows used to move objects) I think I know what you're issue is. Up at the top where it says "center | Local", click center so it changes to "pivot".

    Center will try to put the handles somewhere near the center of the object, taking meshes and child objects into consideration.

    Pivot will put the handles at the exact position of the object without considering the mesh or other objects.
     
  6. angryITGuy

    angryITGuy

    Joined:
    Apr 16, 2020
    Posts:
    3
    I just had the same problem. Using Unity 2019.13f1, i clicked on the generic "move/rotate/scale" tool in the toolbar and the gizmo snapped back to the selected object. This seems to be a bug ?
     
  7. darketernal666666

    darketernal666666

    Joined:
    Dec 22, 2020
    Posts:
    11
    I'm also having a problem where the gizmo is outside of the avatar im making. I really want it to go back to the center. Is there anyway to do it?