Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Using Unity's navigation system for cars on roads

Discussion in 'Navigation' started by DromoDesigner, Sep 13, 2018.

  1. DromoDesigner

    DromoDesigner

    Joined:
    Mar 27, 2016
    Posts:
    7
    Hello,

    I am trying to recreate cars travelling down roads (similar to the roads in Cities:Skylines, but on a smaller scale).

    I am having trouble getting the cars to stick to their side of the road in two-way traffic. I have searched online for a solution or tutorial, but cannot find one.

    Would you please be able to recommend a tutorial or guide on how to get car to travel down roads, so that they stay on the correct side of the road even when turning?

    Thank you,
     
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    159
    From what I know pathfinding on a navmesh might not really be a good idea for this.
    When it comes to cars driving around, you might be better off to define splines for each road that also contain a reference to their connected roads (turns and aheads on crossroads etc) and making your cars follow those instead.
    If you then make sure there's a spline on the road for each direction and provide some splines for making U-turns, you could get a pretty good basis.
     
    DromoDesigner likes this.
  3. thundercat71

    thundercat71

    Joined:
    Sep 13, 2018
    Posts:
    1
    When using nav meshes for simple roads and I do mean simple an invisible barrier down the middle of the road with a nav mesh obstacle applied will work. But this as I said is for simple layouts (grids).
     
    DromoDesigner likes this.