x


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

more ▼

asked Apr 03 '10 at 02:48 PM

MrJames gravatar image

MrJames
35 5 6 11

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I solved the problem by attaching a MeshRenderer component to each object. Than the positionig was correct.

more ▼

answered Apr 20 '10 at 01:36 PM

MrJames gravatar image

MrJames
35 5 6 11

(comments are locked)
10|3000 characters needed characters left

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?

more ▼

answered Apr 03 '10 at 10:09 PM

duck gravatar image

duck ♦♦
41k 92 148 415

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1281
x886
x426
x413

asked: Apr 03 '10 at 02:48 PM

Seen: 1763 times

Last Updated: Apr 03 '10 at 02:48 PM