Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

SOLVED: Animations Make The Model Hover Over Terrain

Discussion in 'Animation' started by Duetschbag, Jun 12, 2014.

  1. Duetschbag

    Duetschbag

    Joined:
    Jun 12, 2014
    Posts:
    10
    I've tried locating similar issues with this and only found one (http://answers.unity3d.com/questions/170719/model-hovers-over-terrain.html). From what I can tell mine is different.

    When I have the "Animation" check box checked on the model, the horse hovers over the terrain. The animations work just fine, but the horse is hovering. If I uncheck the "Animation" check box, the horse is flush with the terrain like it should be but then of course my animations won't play.

    I have adjusted the size of the capsule colider (or character controller I guess) as the other link had suggested, but this doesn't seem to do anything.

    I have screen shots attached and any suggestions would be appreciated. I apologize if some of my terminology is incorrect. I'm still learning. :)

    Scene viewer before playing scene.
    upload_2014-6-12_12-43-32.png

    Playing the scene with "Animation" checked (aka floating effect)
    upload_2014-6-12_12-44-54.png

    Playing the scene with "Animation" unchecked.
    upload_2014-6-12_12-42-52.png
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,748
    This has to do with where the "origin" point is in your animation. If you can't adjust the animation, the best thing to do is to put the animated mesh as a child of your main object (the one with the collider) so you can freely move it relative to your collider.
     
  3. Duetschbag

    Duetschbag

    Joined:
    Jun 12, 2014
    Posts:
    10
    The animation that I am using is the one that came with the free Animated Horse asset in the Unity Asset Store (https://www.assetstore.unity3d.com/en/#!/content/16687). I had to change the animations to legacy (not sure if this is part of the problem) to get them to work and pictured below is how I have everything laid out.

    Is there a way to "zero out" the animation on the mesh or do I just have to remove a component in one spot and add it to another?

    One other thing that I would like to add is that when I change the "culling type" on my animation from "always animate" to "based on renderers" the horse sits normally on the terrain, but then none of the animations work.

    upload_2014-6-13_12-59-38.png upload_2014-6-13_13-0-6.png

    upload_2014-6-13_13-0-47.png upload_2014-6-13_13-1-47.png


    Anything in Root or lower only has a transform component.
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,748
    If you remove the Animation component and move it to another object, it will not be able to find any of the transforms it's animating and your animations will break.

    Rather, remove any other components (CharacterController, etc), add those to a new object, and put the object with the Animation component on it as a child of the new object.
     
  5. Duetschbag

    Duetschbag

    Joined:
    Jun 12, 2014
    Posts:
    10
    To make sure I am understanding you correctly, it should look like this:

    Horse - Contains the Skinned Mesh Renderer (Pictured above)

    New Object - Character Controller, TP Controller, TP Camera​

    Horse - Contains Animations

    Root
     
  6. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,748
    The New Object should be at the top - the Character Controller should have direct control over the position without worrying about being manipulated by other transforms above it. The SMR can be anywhere (it has its own reference to the "root", so it doesn't need to be anywhere in particular, except that it's best to put it within the hierarchy.
     
    ugulati94 and Duetschbag like this.
  7. Duetschbag

    Duetschbag

    Joined:
    Jun 12, 2014
    Posts:
    10
    Thank you so much for this! I don't really understand why I had such a difficult time with this asset. I haven't run into this before but I'm also pretty new to Unity so maybe that's why.

    Just to show what I did you can view the pictures below. The only change I had to make other than rearranging the components was adjust the size of the character controller. Once I did that, the horse stays right on top of the terrain like it's supposed to.

    Now I just have to figure out how to stop it from looking goofy while it's moving up and down hills.

    upload_2014-6-13_22-13-37.png

    upload_2014-6-13_22-13-54.png

    upload_2014-6-13_22-14-21.png