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

Drawing a line between 2 things

Discussion in 'Scripting' started by Findo, May 26, 2014.

  1. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    How would I draw a line between 2 points

    Like a harpoon shooter and the harpoon connected by a line?
    So I have this cube called string. Uh... now what do I do? :(
     
  2. zDemonhunter99

    zDemonhunter99

    Joined:
    Apr 23, 2014
    Posts:
    478
    You can draw lines using a Raycast. Check the tutorials for Raycast. But the thing you're trying to achieve here is different. You need an actual model of a cable or wire, so that it can be connected to the harpoon...
     
  3. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    You could use a line renderer. Just redraw the line each frame.
     
  4. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    ok how do i made a line renderer? :O
     
  5. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Raycasting does not include any mechanisms for drawing lines.

    By using the fancy new API documentation - http://docs.unity3d.com/ScriptReference/LineRenderer.html
     
  6. Warped-Imagination

    Warped-Imagination

    Joined:
    May 18, 2014
    Posts:
    51
  7. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    line Rendering; it has a pinkish square that rotates when i move my camera, so, what now? :/
     
  8. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    How do I script it so it connects 2 points? I got dis so far


    It's uh. not working
     
  9. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    Line renderer works by, setting a material, texture, to define what it loos like, colour included. Also, you can define its two points. Each end. So, up date each end as needed.
     
  10. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    Oh it worked, but it just wasnt in world space xD ty