- Home /
Child ignoring Parent's movment
Hello Folks, I have imported a 3D object into unity. and I have applied a rotation script on it.
using this
**myfridge.transform.Rotate(new Vector3(1f,1f,1f)Time.deltaTime/13, 70);*
now I also want this object to move diagonally across the scene. Since the moment script was getting messed up by the rotation,i thought of a work around. i created an empty game object and applied the moment on it. Edit: here is my movment code
void Update () {
dir = new Vector3(0, 1, -1);
dir = transform.TransformDirection(dir) * speed*30;
}
void FixedUpdate()
{
controller2.Move(dir * Time.deltaTime);
}
Now when i make my original object(with rotation) the child of the game object,it doesn't follow the parent,instead it stays there rotating on the same place.
any help ?
$$anonymous$$y first thought is "uh?" that's definitely the way to go, and it should be working! Are you sure you are moving the right thing? Edit your question and post the movement code!
Answer by whydoidoit · May 28, 2012 at 09:53 AM
So your movement code isn't moving anything :)
You need to update transform.position:
transform.position = transform.position + dir * speed * Time.deltaTime;