Search Unity

How do i code to move objects to follow a certain path ?

Discussion in 'Navigation' started by narf03, Apr 20, 2015.

  1. narf03

    narf03

    Joined:
    Aug 11, 2014
    Posts:
    210


    I get a random image from the net, im not going to use this, but just as example, i want the object to move along the path, following the curve, what is the best way to do it ?

    Thanks
     
  2. proandrius

    proandrius

    Unity Technologies

    Joined:
    Dec 4, 2012
    Posts:
    544
    Well it depends.

    Do you want to calculate this at runtime or in the editor? Do you want to use 2D or 3D?
     
  3. narf03

    narf03

    Joined:
    Aug 11, 2014
    Posts:
    210
    Runtime or in the editor also ok for me, and ... i thought 2D and 3D is perfectly the same in unity, for 2D, just the Y value is fixed.

    Please suggest me a method or a keyword for me to study in that direction, i have nothing in my mind at the moment, thanks.
     
  4. enishii

    enishii

    Joined:
    May 9, 2014
    Posts:
    11
    you can use empty objects to set the patch and lennard jones forces to do the curve effect
    http://en.wikipedia.org/wiki/Lennard-Jones_potential
    the end has a high attraction potential, and repulsive forces on the walls so the object wont collide

    hope this helps
     
  5. narf03

    narf03

    Joined:
    Aug 11, 2014
    Posts:
    210
    are u serious ? i have no idea what did i read =P
     
  6. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    863
    Splines would be a good choice such as in MegaShapes below.

     
    SpookyCat and proandrius like this.