Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How can I make the origin of the parent follow the origin of the child?

Discussion in 'Animation' started by Dan-100, Oct 24, 2023.

  1. Dan-100


    Apr 23, 2023
    Before creating keyframes for this square, the square follows the mouse since I've written that in my code to happen in the game, but then I need this square to have some animations, but as soon as I create a keyframe for its position, the square stops following the mouse as shown below. I haven't even tried to do anything with that animation in my code. You can try this on your own and see if this happens to you too. What is the reason that this is happening?

    I tried to create a parent for the square, and then I made the parent follow the mouse, and I created the animations for the square. The only problem with this approach is that the parent and child would have different origins if the child's position was changed in the animation. What would be the best way to make their origins (gizmo ) the same so that moving the child would make the origin of the parent the same as the child?

    In the top left, there is a "pivot" and "center." When I change both the parent and child to "center," the origin of the parent follows the child, but in the actual game, this does not happen.