Search Unity

How to move an object by using animation?

Discussion in 'Animation' started by CoolCosmos, Sep 25, 2021.

  1. CoolCosmos

    CoolCosmos

    Joined:
    Nov 21, 2016
    Posts:
    246
    Hi there, I have an sphere object which is child of an empty object. Parent object has all of components(including animator.) The sphere is animated to climb the stairs.

    The sphere goes to the first position when animation is over. I want it to climb the stairs everytime i press Space key. How can i move it by an animation ?

    img.png
     
  2. NocturnalWisp

    NocturnalWisp

    Joined:
    Oct 2, 2019
    Posts:
    59
    Hello!

    What you are looking for is root motion. You can read up on it here: Unity - Manual: Root Motion - how it works (unity3d.com) Basically, it allows the object to retain any motion in the world space as apposed to animating in place. (To my best ability at explaining the subject)

    Might I ask why you don't implement this programmatically? It can offer far more manual control.
     
    CoolCosmos likes this.
  3. CoolCosmos

    CoolCosmos

    Joined:
    Nov 21, 2016
    Posts:
    246
    Hi @NocturnalWisp

    I thought it would be easier to move it by using animations. Becuase the sphere is to move one step when i press space key. And it's a 3d game so the sphere is going to move towards to other direction too. So i need to have two animations to move it up(x or z axis) and two animations to move it down(x or z.)

    I have checked the link that you sent. It shows an animation inspector which i couldn't find. As i understand it only shows up when we import a model into the unity. So i still couldn't fix the problem.

    img012.png

    I couldn't find the animation inspector menu that's showed below.
    img120.png
     
    Last edited: Sep 26, 2021
  4. NocturnalWisp

    NocturnalWisp

    Joined:
    Oct 2, 2019
    Posts:
    59
    So, I don't believe you need that inspector at all. Just make sure you add an Animator component to your sphere object and check "Apply Root Motion." Then when you go to animate the object, key in position values (down or up) as well as (left and right). Any position changes you apply to the object will be applied in the world view.
     
    CoolCosmos likes this.
  5. SaraJennifer

    SaraJennifer

    Joined:
    Sep 27, 2021
    Posts:
    1
    You can also select the Selection tool , and point over the object. Then move the object, and drag where ever you want.
     
unityunity