Search Unity

Changing a Prefabs Origin

Discussion in 'Prefabs' started by SimonRigby, May 2, 2019.

  1. SimonRigby

    SimonRigby

    Joined:
    Apr 17, 2015
    Posts:
    1
    Hi all,

    I'm a big fan of the new prefab editing. In my workflow its been excellent but one thing has me stumped. I have a small forest prefab that I've created creating an empty GameObject and dragging my tree model into it three times. I can then scale the different trees to give some variety and all is fine. However, when my map builder places the forest onto game tiles its not quite in the correct place. I would have thought I could just go back into my prefab and move the trees slightly (ie relative to the prefab editor's origin). I can see the transform value change to reflect the new offset, but when instances are placed in the scene by the map builder they ignore the fact that the objects have been offset within the prefab.

    Hope this makes sense and if any one can throw some light on it, it would be greatly appreciated.
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,336
    Prefabs doesn't have an origin. They have a "position", which is kinda weird - it's where they get positioned in the world if you instantiate them without setting a position.
    So there's no "origin" concept in a prefab, just like any other GameObject. Things gets positioned exactly where you put them, and offsets are either due to child objects being moved relative to the parent, or because the mesh contains offsets.

    Does your prefab have a mesh on it's root? If that's the case, you can either modify the mesh' origin, or recreate the prefab with an empty root object so you can position the children relatively.
     
    JonR79 and Wiigoof like this.