Search Unity

Question Simple cube animation plays when creating but won't in game

Discussion in 'Animation' started by ccaporrimo, Nov 7, 2022.

  1. ccaporrimo

    ccaporrimo

    Joined:
    Jun 29, 2016
    Posts:
    2
    Relatively new to Unity / game development though I'm a professional software dev. I'm trying to animate a cube to hover and rotate above my player character. The cube GameObject was created in Unity and is a child of my player character.

    I create an animation using the instructions in the tutorial (Windows > Animation > Animation, create new clip, hit record, change the cube's transformations to create keyframes, and play back. It looks great in scene view during the creation stage. Then I drag animation onto the cube gameobject inspector which creates a simple controller and animator and assigns the controller to it.

    I hit play but the cube is static. I check the controller and it shows the animation is being run but the cube is static. I go into the animation on the controller and try to preview but nothing happens / cube is static. Opening the animation from there shows keyframes as I created them with the correct property transformations.

    I noticed if I open the animation from the Assets folder, my animation properties are yellow saying the model can't be found.

    I couldn't find this scenario searching the internet nor did I find a tutorial on what to do after creating the animation itself. The manual just says to do exactly what I did so I'm very confused. What am I missing?
     
  2. ccaporrimo

    ccaporrimo

    Joined:
    Jun 29, 2016
    Posts:
    2
    Answered my own question. It was because of the Animator on my player game object + the transform properties being hierarchically tied to the player object.

    Solution was to create a new blank game object and make that the parent of my player character and the cube indicator. Moved the player controller and movement scripts onto the parent game object and redid the animation for the cube. All is working now.