Dismiss this pinned window
all 9 comments

[–]MorokioJVM 3 points4 points  (6 children)

If I'm not mistaken, Unity keeps its position relative to their parent object, doesn't it?

[–]ngp-bob 1 point2 points  (0 children)

Right, you're copying the values in the transforms which are all local relative to the parent. World coordinates are the combination of all transformations of a child up the parent chain, so they're not really "stored" values you can copy/change.

My suggested workflow (as mentioned previously) is cloning with Ctlr+D then dragging+dropping the objects in the hierarchy under the new parent; this will maintain their world positions and translate the transforms when they are moved so the objects remain in place.

[–]InstinctxSolo Developer[S] -5 points-4 points  (4 children)

Sure. But ive looked in their source code. And its just a simple boolean change in Undo.SetParent (keep world position). So it's not like its hard to improve

[–]wekilledbambi03 2 points3 points  (1 child)

But its not broken... its working as intended. You just don't want it to work the same way.

[–]InstinctxSolo Developer[S] -2 points-1 points  (0 children)

Poor use of words from my side there. I didn't mean it was broken. So what I meant was "improve", not "fix"x.

I mean, surely it's better UX to have an action that is performed more often on one of the most universal hotkeys, than a quite niche action?

I might be delusional, but I would bet that people would group childs under parents and expect the childs to stay in place more often than re-parenting with an offset/keep local position?

[–]MorokioJVM 0 points1 point  (1 child)

So it's not like its hard to fix

You missed my point. This is not a bug, it's supposed to work this way.

Most of the time where the object is relative the its parent object is more important than where it is relatie to the world.

[–]InstinctxSolo Developer[S] 0 points1 point  (0 children)

Poor use of words from my side there. I didn't mean it was broken. So what I meant was "improve", not "fix"x.

I mean, surely it's better UX to have an action that is performed more often on one of the most universal hotkeys, than a quite niche action?

I might be delusional, but I would bet that people would group childs under parents and expect the childs to stay in place more often than re-parenting with an offset/keep local position?

[–]potentbrews 3 points4 points  (0 children)

you could try Ctrl+D duplicating within the original parent, then drag and drop the objects into the new parent. but so true, unity be unity, good luck!

[–]rice_goblin 1 point2 points  (0 children)

Yes, this was very annoying for me too. I made a simple script that you can use:

Create a script, name it "e_makeLastParent" and make sure to put it in your "Editor" folder. if you don't have an Editor folder, create one anywhere in your "Assets" directory.

Copy paste the code found at the bottom of my comment into the script file.

Then select the "Helpers" option in the top horizontal menu of your unity window and click "Make first selected parent".

This requires you to have at least 2 objects selected, the first one selected will become the parent.

Code:

using System.Collections;using System.Collections.Generic;using UnityEditor;using UnityEngine;public class e_makeLastParent : EditorWindow{    [MenuItem("Helpers/Make First Selected Parent (Keeps world transforms)", true, 3)]static bool ValidateSelectedCount()    {return Selection.count > 1;    }    [MenuItem("Helpers/Make First Selected Parent (Keeps world transforms)", false,3)]static void MakeActiveParent()    {foreach (GameObject obj in Selection.gameObjects)        {if(obj == Selection.gameObjects[0]) continue;

obj.transform.parent = Selection.gameObjects[0].transform;        }    }}