Search Unity

Move gameObject along "track" using joystick?

Discussion in 'PSM' started by pdcstudios, Dec 12, 2014.

  1. pdcstudios

    pdcstudios

    Joined:
    Dec 28, 2012
    Posts:
    8
    I have a gameObject that sits on a curved "rail" track like a quarter circle. I'm trying to get it to move with the left joystick left or right along the track. So far I've only been able to go in a straight line on the x or y axis. Not both. Does anyone have any tips on how to do this or can point me in the right direction? Thank you!
     
  2. zbiat

    zbiat

    Joined:
    Apr 3, 2014
    Posts:
    6
    The simplest way to do this is to create an array of points which your gameobject will transpose along, you can then select one joystick direction to increment the next point in the array and the other joystick direction to decrease to the previous point in the array. Your gameobject will lerp from its current position to the nearest point in the array until it reaches the seleceted point.