Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

[Solved] Change end position of gameObject animation

Discussion in '2D' started by Krakord, Aug 11, 2019.

  1. Krakord

    Krakord

    Joined:
    Aug 5, 2019
    Posts:
    3
    Hello everyone,

    I am new in Unity and love it ! But i have also some "beginner" question.
    I have a simple question and i have search and search without finding a correct response.

    Here is my context. I have an hexogonal map and a coin wich appears in random cell.
    When i click on the coin, i want it to animate (rotate, rescaled and move to the other coin on the left position).

    My problem :
    - the coin move when i click on it (ok)
    - the coin animation is correct except that it is not going to the right place.
    => Indeed the animation move is translated in function of the initial random position of the coin (the only case in good condition is when my coin appears in the same position as when i created the animation.

    In fact i need a relative start position (that's working) and an absolute end position

    How do i do it ?

    I am using animator and i thinks i need to change in script an animation.setCurve but i don't know how to adress it properly...

    upload_2019-8-11_10-32-13.png
     
  2. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    144
    It would be better if you used a tweening solution for this.
    Tween.Move(initPos, endPos, duration)
    this is a generic method and will not work, its just an example

    there are a lot of tweening assets, i use Leantween
     
  3. Krakord

    Krakord

    Joined:
    Aug 5, 2019
    Posts:
    3
    Super it works fine !
    Is it a license free library ?

    ie : if i want to moneytize my game do i have to reverse some benefit to LeanTween ?
     
  4. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    144
    Its completely free, no profit to be shared. But you may rate his asset highly and try some of his paid stuff. If you are feeling generous you may credit him in your game or donate some money to him (its not mandatory).
     
  5. Krakord

    Krakord

    Joined:
    Aug 5, 2019
    Posts:
    3
    Thank you very much, i will go looking after it !
     
unityunity