Search Unity

How to move object from one x coordinate to another x coordinate?

Discussion in 'Animation' started by jeremy_crowell, Sep 10, 2018.

  1. jeremy_crowell

    jeremy_crowell

    Joined:
    Jul 21, 2018
    Posts:
    83
    Hello,

    I have an object, simple popup. I need to move it from coordinates (0, 0, 0) to (100, 0, 0). How can this be done in Unity?

    I tried to use animation, and record movement, but later when I added some graphic to the object, movement on the cheap mobile lost its smoothness. I think when I finish decoration(e.g. add more images to the object) the moving on mobile will be even worse.

    Any advice is appreciated.
     
  2. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    Have a look at DOTween, from the Asset Store there's a free version. It's one of the easier ways to move things in Unity. Unity doesn't come with movement functions like you might see/expect in a game engine. It's one of its oddities.
     
  3. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Or you can use position = lerp (position a, position b, amount percentage)
     
  4. jeremy_crowell

    jeremy_crowell

    Joined:
    Jul 21, 2018
    Posts:
    83
    Thank for answers to everyone. But maybe I come with wrong name of action.

    Before I was developing games with Phaser, and there I had an action "TWEEN" with parameters, (x,y) as start, (x1, y1) as end point and speed of movement.

    I can't believe that Unity doesn't have such action implemented by default. I still believe that I'm missing something. Moving objects from one point to another is base of any 2D game and 3D as well.
     
    Deeeds likes this.
  5. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    This is EXACTLY why I'm suggesting you look at DOTween.

    Look at the name.

    It's a Tweening library.

    It's not the best documentation in the world, but it is quite powerful and fun to use... so if you have questions about it, ask in this thread, and I'll try to explain how to use it. It's actually pretty cool.

    But I do agree with you, completely, it is stunning that there's not a functional tween library built into Unity.
     
    jeremy_crowell likes this.
  6. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739

    I've recently found another tweening library, that's super cool, and minimalist: https://github.com/beinteractive/Uween

    // I haven't yet tried it, but the simplicity and elegance of the thing is stunning. How things should be!


    I have been almost exclusively using Animation (Legacy) Components for everything that doesn't need to be dynamic... and DOTween and/or physics for dynamic stuff.