Search Unity

Question Animation starting from anywhere moving to position x?

Discussion in 'Animation' started by MrScreeps, Sep 24, 2020.

  1. MrScreeps

    MrScreeps

    Joined:
    Feb 26, 2020
    Posts:
    2
    I am seriously desperate. Is it possible to create an animation in the animator where you don´t give it a start value? So f. E. I want to move a box from wherever it is to position.x with the value of 50? I love the animator but this is something i desperately need and I don´t want to write a script for that.

    Alternatively: Can you change values in an animation via a script? Although I´m pretty sure already that the answer to that is "no".

    Is there anyone who can help me ?

    To clarify: this is one part of one of my animations:
    Animator with starting point.PNG

    If I delete the first keyframe, it changes to this:
    animator without starting point.PNG

    How can I set a begining keyframe of just wherever its current X position is.

    Edit: Follow up question. I tried to do the anywhere to x part in a script. But it does seem like you cant animate things in a script while having an animator running at the same time. Is there a way around this?
     
    Last edited: Sep 24, 2020
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    No to all your first questions. Doing it in a script is the way to go (or try out some of the tween plugins on the Asset Store). You just need to run your code in LateUpdate and be aware that any value controlled by an animation will be overwritten by the animation every frame, so you will need to set it again every LateUpdate (or not have any animations controlling that value).
     
    MrScreeps likes this.
  3. MrScreeps

    MrScreeps

    Joined:
    Feb 26, 2020
    Posts:
    2
    That was the problem with the script yes. I already checked that but forgot that there is another animation in the animator that does work with that value still.
    So thanks for confirming that.

    And thanks of course for your answer. Now I know that I need to do it like this.