- Home /
Moving a GameObject reffering to the coordinates of the parent Object
Greetings,
As the tile says, I would like to move a Gameobject reffering to the parent Gameobject. But when I try to do so via C# I can not change the position reffering to the parent Gameobject but to the "global" coordinates..Is there a way to change that?
For example, I try to use
for(int j = 0; j<5; j++){ button[j].transform.position = Vector3.Lerp(button[j].transform.position, new Vector3(button[j].transform.position.x, 1,4f, button[j].transform.position.z), t); }
The Gameobjects got 1,4 as y-coordinate within the parents coordination system, and I would like to use that. But it appears to be not that simple^^ I guess I have to change the point from where I get my coordinates in the code. An if I'm done with that, how would I change them back?
Thanks for any help.
Answer by iwaldrop · May 03, 2013 at 08:35 PM
Are you talking about using transform.parent.position.y, or transform.localposition.y?
Transform.localposition was just the thing I need =) Thanks dude =) Since you made "just" a comment I can't mark your answer as right :/
I've converted it to an answer so you can accept it. Glad it helped.
Your answer
Follow this Question
Related Questions
"Center On Children" programmatically 1 Answer
Instantiated GameObject gets spawned as a child 2 Answers
Can one specify the parent of a gameobject in an array? 2 Answers
Accessing variable from parent 1 Answer
Make a simple tree 1 Answer