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
  4. Dismiss Notice

Connect two points with dotted line

Discussion in 'Getting Started' started by EvgeniiPtn, Oct 4, 2020.

  1. EvgeniiPtn

    EvgeniiPtn

    Joined:
    Apr 11, 2020
    Posts:
    3
    Hello, I'm implementing a map for an RPG game.
    The idea is simple - character will be able to move on predefined "points", let's call them POS(point of interest).
    Those points will have connections between them so the player will know where he can go and where he can't.

    Map.png

    I have some concerns about how to better implement this logic.
    At this point, I've created two prefabs - for POS(green) and for path-dot (yellow).
    Then, I'm calculating the distance between green dots and draw yellow dots between.

    I have feeling that there is a better approach, maybe I can use som OOTB (out of the box) unity tool to draw such "lines"?
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    Hey! I made an asset that does this! Not saying you need to buy it (but you can!), but I wanted to flash my credentials at the start.

    You can absolutely do things the way you described. If you only care about rendering in 2D, the LineRenderer component can be given a texture to use as a dotted line. If you want them to be 3D, you'll have to determine the distance, and what your min/max spacing is, and then iterate through and add objects at points along the way.

    There's more to it, obviously, or I wouldn't have made a whole asset to handle doing it. But that should get you started. Let me know if you need more help as you go!
     
  3. EvgeniiPtn

    EvgeniiPtn

    Joined:
    Apr 11, 2020
    Posts:
    3
    Thank you a lot!
    At this point will go with the solution I've described.

    The asset looks great!
    I already have a lot of issues with my approach that is required to cover (a lot of corner cases with drawing connections) and in your asset it clear from screenshots that it's covered.
     
  4. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,510
    Yeah, there's still problems I or others have discovered with my asset. I haven't been maintaining it the way I'd like to, but it's on my ToDo list to either add the enhancements or rewrite the thing.

    Seriously, if you run into other problems, just reach out. I'm happy to help!