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

Draw flat line in Unity

Discussion in 'Scripting' started by hum642tic144, Jun 22, 2022.

  1. hum642tic144

    hum642tic144

    Joined:
    Feb 4, 2022
    Posts:
    18
    Hi, I have implemented a functionality that allows the user to draw lines by clicking on a terrain. I make these lines with the LineRenderer component and from a 2D view they look good but the problem comes when I change to a 3D view as lines are not flat. I need these lines to be flat and always looking upwards (as if it were a plane) and I don't know how to do it. I saw that LineRenderer has an Aligment attribute but the options are View and TransformZ and what I need is TransformY.

    2D view


    3D view


    Thanks!
     
    Last edited: Jun 22, 2022
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    On the LineRenderer use TransformZ and world space positioning. Then set the GameObject's rotation to 90 degrees on the X, and it should behave how you'd like.
     
  3. hum642tic144

    hum642tic144

    Joined:
    Feb 4, 2022
    Posts:
    18
    It worked!

    Thanks!
     
    GroZZleR likes this.