Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Object goes to origin during animation

Discussion in 'General Discussion' started by zacharyhunterlund, Jan 21, 2022.

  1. zacharyhunterlund

    zacharyhunterlund

    Joined:
    Mar 7, 2021
    Posts:
    53
    Hello,

    I am making a game, and I have a spike bush that is supposed to sway when you touch it. I made the animation, but whenever it plays in game, the object goes to (0,0,0) during the animation, then snaps back to its original position during the idle phase. How do I fix this?

    Edit: Also, if I try to change the object's scale, it goes back to its original scale during the animation as well.
     
    Last edited: Jan 21, 2022
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,611
    The only reason I could imagine this happening is if you're animating the root bone, or if the bone(s) for the bush don't have a root bone it's parented to, thus shifting the bone to where you animated it in your 3d program.

    It's always good practice to have a root bone for any armatures, one that isn't skinned to anything, but it used to position the rest of the rig in world space.
     
  3. zacharyhunterlund

    zacharyhunterlund

    Joined:
    Mar 7, 2021
    Posts:
    53
    My animation actually does not have a bone. It simply rotates the object.
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,611
    Was this animated in Unity or in a 3d program?

    In the latter's case, when it comes to export time it's probably written location key data alongside the rotational data. So if you've got your bush at 0,0,0 in your 3d program, come animation time it's gonna use that location data.

    Simplest solution I can think of is to do more or less the same thing, but in this case just child the bush to a parent empty, that way it's movement should remain local to its parent object.
     
    macka1080 likes this.
  5. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,084
    Can we see some code or anything to help us accurately diagnose this?
     
  6. zacharyhunterlund

    zacharyhunterlund

    Joined:
    Mar 7, 2021
    Posts:
    53
    It was animated in Blender. I wonder how I can fix this?
     
  7. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,611
    Um, did you try what I suggested? Child the animated object to a parent empty, so it's only being rotated locally to its parent.

    As mentioned in animation/rigging you should always have a root object that just acts as a means to position the rig.
     
  8. zacharyhunterlund

    zacharyhunterlund

    Joined:
    Mar 7, 2021
    Posts:
    53
    Oh sorry, I'll try that. Thank you.

    EDIT: It works for the position, but for some reason the scale changes during the animation.