Search Unity

Simple algorithm to generate grid road from point to point

Discussion in 'Scripting' started by LoopIssuer, Jan 27, 2020.

  1. LoopIssuer

    LoopIssuer

    Joined:
    Jan 27, 2020
    Posts:
    109
    Hi,
    I have problem with creating 'for' loops to generate tile based road from point to point. It should looks like on the pictures with examples - road should 'break' symmetrically depending on the start and end coordinates in all directions.
    upload_2020-1-27_8-28-55.png upload_2020-1-27_8-30-57.png

    Thanks for help in advance!
     

    Attached Files:

  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
  3. LoopIssuer

    LoopIssuer

    Joined:
    Jan 27, 2020
    Posts:
    109
    Thank you.
    But how to 'translate' this to c#?
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
  5. LoopIssuer

    LoopIssuer

    Joined:
    Jan 27, 2020
    Posts:
    109
    Thank you very much.
    It works very well.
    Can I use your implementation for my project? Is it cc0?
     
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
    yes go ahead, i've converted it from that wiki article example