So I have an airplane, which is a child of an empty object. Click a button, airplane flies forward and stops. Click button again, the airplane flashes back to it's starting point to begin the animation again. I want the plane to keep flying along from it's current position, so I need to sync the parent's transform with the plane's current location at the end of the animation, right? I tried: parent.transform.position = this.transform.position; Seems to put the parent in correct location, but then the child maintains it's relative position and jumps forward. Someone suggested... transform.localPosition = Vector3.zero; ...Immediately after, but that didn't help either. I've done a lot of searching but couldn't find an answer, so any hints would be appreciated.
No, I wouldn't think so. Let's back up. What's causing the plane to fly forward? What code runs when you click the button?
Clicking the button just calls the animation.Play function for the plane. The animation itself is just a simple animation I created in the animation widow.
So with some help I got the position correctly updating. Code (csharp): void Start() { relRot = this.transform.rotation * Quaternion.Inverse(parent.transform.rotation); } public void updateParent() { parent.transform.position = this.transform.position; transform.localPosition = Vector3.zero; parent.transform.rotation = relRot * this.transform.rotation; animation.Play("idle"); } Got it working with the above.