Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Creating Trains that follow Rails, and Cars that follow Roads?

Discussion in 'Getting Started' started by PetherP, Aug 8, 2015.

  1. PetherP

    PetherP

    Joined:
    Aug 7, 2015
    Posts:
    4
    I am trying to build a City Building game where I want to be able to build roads and railroads and have trains and cars follow them. I have found iTween that lets you create paths and have objects move constrained to them. But as i understand it, you don't create these paths at run time, so you can't do it while playing the game? Seems like it's more for platformers then strategy.
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,148
    My understanding is you can modify the path at runtime so long as you use PutOnPath() or PointOnPath() to position the object along the path. I don't know if you're able to create a new path at runtime though.

    You could try an alternative like Curvy. Its description states it can create paths at runtime.

    https://www.assetstore.unity3d.com/en/#!/content/7038
     
    Last edited: Aug 8, 2015
  3. PetherP

    PetherP

    Joined:
    Aug 7, 2015
    Posts:
    4
    Ok. I'll look those up. And path's are just normal vector 3's? Can i use Vector 2's if it's 2d? Or just leave the third zero?
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,148
    Yep, you leave one of the axis (usually Z) a zero if you want 2D.