Unity minecart 2d idea

Hello everyone. I am new to Unity and I wonder if someone could help me with my game 2D any idea how to do. The idea is to make the cart can walk between independent rails as in this video: - YouTube

I’ve heard in ITween but I can only make it stand following a path

Let’s assume iTween, because if we open it up, this question has a lot of possible implementations and becomes a design question better posted on Unity Forums.

  • Define two parallel paths in iTween. There is a free visual path editor for iTween you can get here, but you can also define your own array of Vector3s or array of Transforms.
  • Use iTween.PutOnPath() and iTween.PointOnPath() for placing and moving objects on the path (not the orienttopath for things like MoveTo()).
  • PutOnPath() and PointOnPath() use a fraction between 0.0 and 1.0 where 0.0 is the beginning of the path and 1.0 is the end of the path. If you get the current position and then a position slightly ahead of the current position, you can produce and direction and from that an angle. This gives you the needed information to angle your cart and to calculate the physics (go faster downhill and slower uphill).
  • To switch paths, use the same fraction but replace the array used. Here is an answer for someone doing that with iTween.
  • In the link just provided, you will also see code that increments the fraction from 0.0 to 1.0 and therefore move the object along the path.
  • The physics of swapping I’d handle by moving an empty game object along the path with the visible object a child. When switching paths, the empty game object moves immediately, but the physical game object lags and is Lerp()ed or MovedToward()ed using Trandform.localPosition. Here is a similar question to give you an idea.