- Home /
Position of parent-Object
Hi,
my project has a groundplane which symbolised the floor of my room. I have an empty gameobject called "ground-grid", created within a script. The script creates many sub-grids (smaller size) and adds every single grid to my "ground-grid".
subgrid[rxy].GetComponent(Transform).parent = groundgrid.transform;
"Randomly" my script creates 2x2-Grids (to use for such sized objects later). If such a grid appears, the script creates another empty gameobject called the number of currently existing 2x2-grids.
Here's an example of the hierarchy:
ground-grid (empty go) > ... 18,19,20,21, ...
2x2-grid (empty go) > 1 (empty go) > 7,8,17,18
> 2 (empty go) > 28,29,38,39
For the sake of convenience i just want to place a 2x2-Obj on parent. For example on "1".
The problem is, that the empty go "1" is positioned in the middle of the for sub-grids, but has the transform.position coords of (0,0,0). If i want to position my object on the same coords it appears in the center of the world (because thats 0,0,0). Can you tell me, how to let the parent go have the right coords?
Greetings, MrJames
Answer by MrJames · Apr 20, 2010 at 01:36 PM
I solved the problem by attaching a MeshRenderer component to each object. Than the positionig was correct.
Answer by duck · Apr 03, 2010 at 10:09 PM
I may not be fully understanding your question, but could it be that you're just looking to set the object's localPosition rather than its world position?
Your answer
Follow this Question
Related Questions
Transform child object over time and then destroy it. 1 Answer
Parent transform not following child transform 0 Answers
Problem with making child an object 2 Answers
Make a simple tree 1 Answer
Camera follow ball along cylinder 1 Answer