Search Unity

Vectrosity - fast and easy line drawing

Discussion in 'Assets and Asset Store' started by Eric5h5, May 26, 2010.

Thread Status:
Not open for further replies.
  1. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    OK, you are creating a VectorCam yourself, that's what I thought at first. ;) You don't need to do this (and in fact shouldn't do it); Vectrosity creates the VectorCam for you automatically when needed. You can also use VectorLine.SetCamera if you want the VectorCam to be set up with some non-default parameters.

    --Eric
     
  2. WarbladerToo

    WarbladerToo

    Joined:
    Nov 2, 2009
    Posts:
    96
    Got it now... I thought the SetCamera was working in a different way... :) I figured it out now (I hope)

    Thanks!!
     
  3. aliakbo

    aliakbo

    Joined:
    Jan 28, 2012
    Posts:
    35
    Hey,

    I was wondering if Vectrosity could turn the lines on the screen into GameObjects with Rigidbodies.

    And if it cant, how would I implement this?

    Just for clarity, I am making a 2D side-scroller where the player draws onto the screen and the drawing should turn into a rigidbody.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It won't do that out of the box, but apparently someone added their own code to extrude the line mesh in order to do something like this.

    --Eric
     
  5. aliakbo

    aliakbo

    Joined:
    Jan 28, 2012
    Posts:
    35
    Thanks for the reply,

    Do you know where I can find this? Or where this was done?
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's not something you can find, since that person did it himself. You'd have to be familiar with the Mesh class. Since Vectrosity wasn't designed for this, I'm not sure if it wouldn't be easier to do it from scratch.

    --Eric
     
  7. WarbladerToo

    WarbladerToo

    Joined:
    Nov 2, 2009
    Posts:
    96
    I have a bit of problem with the MakeCurve function. When I add any number of curves to my curveline object, it always draw a extra line back to (0,0,0) This is using Vector3 points and Draw3D

    $curves.jpg

    Code (csharp):
    1.  
    2.     void DrawWaves()
    3.     {
    4.         for(int i = 0; i < (int)CurveSizes.N_WAVES; i++)
    5.         {
    6.             if(Menu_script.Level.waves != null  Menu_script.Level.waves[i].active)
    7.             {
    8.                 VectorLine.Destroy(ref StartPoints[i]);
    9.                 StartPoints[i] = new VectorLine("StartPoints",new Vector3[circle_segments+1],linematerial,2.0f,LineType.Continuous);
    10.                 StartPoints[i].active = true;
    11.                
    12.                 VectorLine.Destroy(ref Curves[i].Curve);
    13.                 Curves[i].Curve = new VectorLine("Curve",new Vector3[((int)CurveSizes.N_CURVE_SEGMENTS+1)*(int)CurveSizes.N_CURVES_IN_WAVE],linematerial,2.0f,LineType.Continuous);
    14.                 Curves[i].Curve.active = true;
    15.                
    16.                 StartPoints[i].MakeCircle(Menu_script.Level.waves[i].startpos,Vector3.forward,1.0f,circle_segments);
    17.                 if(ActiveWave == -1) ActiveWave = i;
    18.                
    19.                 int n = Menu_script.Level.waves[i].n_curvesections;
    20.                 for(int c=0; c < n; c++)
    21.                 {
    22.                     // This is just to check the data....
    23.                     Vector3 p1 = Menu_script.Level.waves[i].curve_sections[c].start;
    24.                     Vector3 c1 = Menu_script.Level.waves[i].curve_sections[c].ctrl_start;
    25.                     Vector3 p2 = Menu_script.Level.waves[i].curve_sections[c].end;
    26.                     Vector3 c2 = Menu_script.Level.waves[i].curve_sections[c].ctrl_end;
    27.                     int cs = (int)CurveSizes.N_CURVE_SEGMENTS;
    28.                     int indx = ((int)CurveSizes.N_CURVE_SEGMENTS+1)*c;
    29.                     Curves[i].Curve.MakeCurve(    p1,    c1, p2, c2, cs, indx);
    30.                 }
    31.                 if(i != ActiveWave)    
    32.                 {
    33.                     StartPoints[i].SetColor( new Color(0,1,0,1) );
    34.                     Curves[i].Curve.SetColor( new Color(0,1,0,1) );
    35.                 }
    36.                 else
    37.                 {
    38.                     StartPoints[i].SetColor( new Color(1,1,1,1) );
    39.                     Curves[i].Curve.SetColor( new Color(1,1,1,1) );
    40.                 }
    41.             }
    42.             else
    43.             {
    44.                 VectorLine.Destroy(ref StartPoints[i]);
    45.                 StartPoints[i] = null;
    46.                 VectorLine.Destroy(ref Curves[i].Curve);
    47.                 Curves[i].Curve = null;
    48.             }
    49.             if(StartPoints[i] != null) StartPoints[i].Draw3D();
    50.             if(Curves[i].Curve != null) Curves[i].Curve.Draw3D();
    51.         }
    52.     }
    N_CURVE_SEGMENTS = 60
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use .maxDrawIndex, or possibly .drawEnd depending on what you're doing. Or you can make sure that every point in the array is used, since any "leftover" points will be Vector3.zero, and continuous lines always connect every point to the next one.

    --Eric
     
  9. WarbladerToo

    WarbladerToo

    Joined:
    Nov 2, 2009
    Posts:
    96
    Yes that was what I found out (thinking about the bug.. not tested in code) too. That it was all the empty (vector3.zero) data in there that made it like that.

    Thanks anyway!!
     
  10. jbarrett98121

    jbarrett98121

    Joined:
    Jan 3, 2011
    Posts:
    251
    yo! great product :)

    I have a question though. I am using the "Path" script in a project of mine similar to angry birds to display a trajectory path behind the ammo object hat has been shot out of the slingshot.

    It works nicely! I have modified the script a bit and attached it to my ammo object, and yes it does display the trajectory path when it is shot.

    what i have a question about figuring out though, is how to REMOVE the trajectory path after the object the path script is attached to has been destroyed from the scene. (ie .. right now the ammo object is shot, bounces around on the ground for a while, and is destroyed, but the trajectory path remains as long as the scene is played)

    how do i destroy that trajectory line once the object has been destroyed?

    here is a link to the thread which has the script I have modified (it's the same script in the demo minus giving the ball force and instantiating it)
    http://forum.unity3d.com/threads/144075-Drawing-a-Trajectory-behind-a-projectile-(angry-birds-style)

    thanks!
     
    Last edited: Jul 18, 2012
  11. jbarrett98121

    jbarrett98121

    Joined:
    Jan 3, 2011
    Posts:
    251
    i'm trying to use

    if (ballPrefab.transform == null)
    {

    Vector.DestroyLine(pathLine);
    }

    but that's not working....

    what would be the right condition to check if the ballPrefab exists in the current scene? or to check if it has been destroyed or not?
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Check if the object is null and use VectorLine.Destroy. (I'd suggest upgrading to the latest version.)

    --Eric
     
  13. rsodre

    rsodre

    Joined:
    May 9, 2012
    Posts:
    229
    Hello!

    Just bought Vectrosity, great job!

    I've got a little problem, I'm creating multiple VectorLines, but only the first one passed to VectorManager.ObjectSetup() is drawn, all the other ones are not. I'm sure all VectorLines are ok, because if I change the VectorManager.ObjectSetup() order, I can see the other lines being drawn. What am I doing wrong?

    Code (csharp):
    1.  
    2.     var lv0 : Vector3[] = lines0.ToBuiltin(Vector3);
    3.     vecLines[0] = new VectorLine("TerrainLines0", lv0, linesMaterial, 1.0, LineType.Discrete);
    4.     vecLines[0].AddNormals();           // avoid shader warning
    5.     var lv1 : Vector3[] = lines1.ToBuiltin(Vector3);
    6.     vecLines[1] = new VectorLine("TerrainLines1", lv1, linesMaterial, 1.0, LineType.Discrete);
    7.     vecLines[1].AddNormals();           // avoid shader warning
    8.     var lv2 : Vector3[] = lines2.ToBuiltin(Vector3);
    9.     vecLines[2] = new VectorLine("TerrainLines2", lv2, linesMaterial, 1.0, LineType.Discrete);
    10.     vecLines[2].AddNormals();           // avoid shader warning
    11.     var lv3 : Vector3[] = lines3.ToBuiltin(Vector3);
    12.     vecLines[3] = new VectorLine("TerrainLines3", lv3, linesMaterial, 1.0, LineType.Discrete);
    13.     vecLines[3].AddNormals();           // avoid shader warning
    14.     // setup 3D
    15.     VectorManager.useDraw3D = true;     // depth test
    16.     VectorManager.ObjectSetup( gameObject, vecLines[0], Visibility.Dynamic, Brightness.None, false );
    17.     VectorManager.ObjectSetup( gameObject, vecLines[1], Visibility.Dynamic, Brightness.None, false );
    18.     VectorManager.ObjectSetup( gameObject, vecLines[2], Visibility.Dynamic, Brightness.None, false );
    19.     VectorManager.ObjectSetup( gameObject, vecLines[3], Visibility.Dynamic, Brightness.None, false );
    20.  
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Hi, you should use a different GameObject with each ObjectSetup call. In the same way you wouldn't have more than one MeshRenderer for a GameObject, you wouldn't have more than one "Vectrosity line renderer" for a GameObject either.

    --Eric
     
  15. amasinton

    amasinton

    Joined:
    Aug 12, 2006
    Posts:
    138
    Hi Eric and everyone,

    First, Eric, I got the planetarium working using Vectrosity to plot the stars correctly. Thanks very much for you help! Will post a demo when it's presentable.

    Second, I've got a line made up of a series of Vector3s. Is there a way that I can 'grow' this line? The effect I'm going for is to have it draw itself onsceen at runtime, starting from the start and reaching the end over a period of time. Any way to do this in Vectrosity?

    Many thanks!

    -- Anthony
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can use VectorLine.drawEnd.

    --Eric
     
  17. rsodre

    rsodre

    Joined:
    May 9, 2012
    Posts:
    229
    Like this...?
    Still not working.

    Sorry if it is too trivial, but that's my first Unity project, I'm still learning, and don't get this concept.
    When I hit PLAY, I can see that an independent game object "Vector <linesname>" is created, with its own meshrenderer. Why does it need another gameObject?

    Code (csharp):
    1.  
    2.     var lineobj0 : GameObject = new GameObject ("TerrainLines0_obj");
    3.     var lv0 : Vector3[] = lines0.ToBuiltin(Vector3);
    4.     vecLines[0] = new VectorLine("TerrainLines0", lv0, linesMaterial, 1.0, LineType.Discrete);
    5.     vecLines[0].AddNormals();           // avoid shader warning
    6.     VectorManager.ObjectSetup( lineobj0, vecLines[0], Visibility.Dynamic, Brightness.None, false );
    7.  
     
    Last edited: Jul 20, 2012
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Are you sure you should be using ObjectSetup? Have a look at the docs which explain ObjectSetup, and the demos, most of which don't. You'd only use it if you want to have a VectorLine that behaves like a GameObject; most often you use VectorLine.Draw or Draw3D.

    --Eric
     
  19. rsodre

    rsodre

    Joined:
    May 9, 2012
    Posts:
    229
    I was copying from the simple3dlines demo, I don't need the gameobject at all.
    Much simpler and working now, thanks!

    Code (csharp):
    1.     var lv0 : Vector3[] = lines0.ToBuiltin(Vector3);
    2.     vecLines[0] = new VectorLine("TerrainLines0", lv0, linesMaterial, 0.5, LineType.Discrete);
    3.     vecLines[0].AddNormals();           // avoid shader warning
    4.     vecLines[0].Draw3D();
    5.  
     
  20. nitz

    nitz

    Joined:
    May 4, 2011
    Posts:
    54
    Hi Eric, I had another question for you!

    I'm trying to create some charts and graphs using Vectrosity, and I've been able to get them all laid out and displayed nicely. For my next trick, I wanted to have it displayed on a texture that's drawn with the GUI. My method for this was to set the render target of the vector camera to be a render texture that I generated, then drawing that as I needed too. The results of that worked out rather perfectly:



    As I've now moved on to wanting to create additional charts, I've realized that I'm not sure I can, or at least am not sure how to work your API to achieve my desired effect.

    Naturally, I want to have multiple cameras to have multiple render targets, so that I can have -- you guessed it -- multiple charts. Though, It seems the SetCamera function only holds on to the last camera I give it, and shares it as a static variable across anything using Vectrosity. Is there a way to trick it into only rendering certain lines to certain cameras? Or if that's not possible, perhaps a way to have several cameras in different spots so as I can do line.Draw() in front of those particular cameras? Am I even making any sense? :)

    Thanks again for the help!
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Hmm...tricky. Do the charts change much? If not, it seems like for each chart you could render just the one chart (disabling the others), do a render to texture, and use ReadPixels to convert that to a texture that could be used in the GUI.

    --Eric
     
  22. nitz

    nitz

    Joined:
    May 4, 2011
    Posts:
    54
    Thanks Eric!

    I took your idea and extrapolated on it a bit. I have a controller class that keeps up with all my charts. My controller has a co-routine that's started from update if it's not running, that will go through all the charts I have. If it finds one that needs to be re-drawn, it redraws it and yields, otherwise it just goes to the next one. This way I am only ever drawing 1 chart a frame. (This has the possibility to slow down the appearance of things if I have several dynamic charts, but for my application it works just fine!)

    Thanks for your help!
     
  23. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    Hi Eric,

    I am trying to use Vectrocity to get an object to follow a spline and that works well, but I need the object to angle itself based on the slope of the
    line where it currently is. So basically pointing in line with the line. Any ideas how to do that with your plugin?
     
  24. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You could have the object LookAt() the next point.

    --Eric
     
  25. badawe

    badawe

    Joined:
    Jan 17, 2011
    Posts:
    297
    Hey Eric, i want to achieve some effect, but i can't understand how do that with Vectrosity!

    What I want is quite simple, i have one moving ball going forward in relation of my Camera, but the line always look the same size for me, I need to make this looks more realistic, as far the ball go, the width of the line get smaller. What i have is this:

    Code (csharp):
    1.  
    2. void Start()
    3.     {
    4.         pathPoints  = new Vector3[iMaxPoints];
    5.         pathLine    = new VectorLine("Path", pathPoints, matLine, 7f, LineType.Continuous);
    6.        
    7.        
    8.         StartCoroutine("SamplePoints");
    9.        
    10.     }
    11.     void DrawPath ()
    12.     {
    13.         if (pathIndex < 2) return;
    14.         VectorLine.SetCamera3D();
    15.         pathLine.maxDrawIndex = pathIndex-1;
    16.        
    17.         pathLine.drawEnd = pathIndex-1;
    18.        
    19.         if(pathIndex > iLineDistance)
    20.         {
    21.             pathLine.drawStart = pathIndex-(iLineDistance-1);
    22.         }
    23.        
    24.         //pathLine.SetTextureScale (2.0f);
    25.        
    26.         pathLine.Draw3D();
    27.        
    28.     }
    29.     IEnumerator SamplePoints()
    30.     {
    31.         while (bDraw)
    32.         {
    33.             pathPoints[pathIndex] = this.transform.position;
    34.             if (++pathIndex == iMaxPoints)
    35.             {
    36.                 bDraw = false;
    37.             }
    38.             yield return new WaitForSeconds(.05f);
    39.            
    40.             //DrawPath();
    41.         }
    42.     }
    43. void Update()
    44. {
    45.         DrawPath();
    46. }
    47.  
     
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's actually going against what Vectrosity is meant to do. It sounds like you'd be better off with a LineRenderer in this particular case.

    --Eric
     
  27. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    Is there a trick to switching scenes when using Vectrosity?
    I load a new scene and get null ref errors about missing Camera and Transform in the console. It seems like it is to do with LineManager not being destroyed on load and using ObjectSetup in the new Scene ??

     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Make sure you use SetCamera3D after changing scenes, or else make sure the 3D camera (which is Camera.main unless otherwise specified) is not destroyed when loading new scenes.

    --Eric
     
  29. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    *EDIT* Ok, that worked using SetCamera3D, thank you!
     
    Last edited: Aug 1, 2012
  30. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    How? I can't find how to get the current point on the line. Say I have 6 nodes and the curve is drawn connecting them all up, I can find my position on the line but not which node is next to be able to lookat it.
     
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You could make use of the distances array for VectorLines...it's currently private, but you could add a bit to the source code. After the "float[] m_distances;" line in VectorLine.cs, add this:

    Code (csharp):
    1.     public float[] distances {
    2.         get {return m_distances;}
    3.     }
    That way, for example, if myLine.distances[4] was 50.0 and myLine.distances[5] was 100.0, and your current distance was 70.5, you'd know the next point is 5.

    --Eric
     
  32. amw157

    amw157

    Joined:
    Jun 11, 2012
    Posts:
    6
    I searched the forums for this, honest I did! I also read the documentation.

    I'm just getting started with MakeRect. I'd like to fill the rectangle with a color, or material, or texture ... and I don't see any options for doing that. I know how to set a material for a VectorLine, and that works, but how do I FILL the rectangle?
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Vectrosity doesn't currently have any support for filled shapes; it's meant for line-drawing.

    --Eric
     
  34. amw157

    amw157

    Joined:
    Jun 11, 2012
    Posts:
    6
    Thanks for the reply, Eric.

    Next question ... Can the order in which GUI and Vectrosity are rendered be controlled?

    I'm making a GUI.Window, with all kinds of labels and buttons.

    I'm drawing some VectorLines and rectangles into the Window ... by using the window's current X-Y offset and height/width as cues for where the lines should be drawn. When the window moves, the lines move because of this. It looks like the lines are PART of the window, but it's just a trick.

    I want the Vectrosity lines to be rendered after the window is rendered. Right now it appears that the window background is painted on top of the Vectrosity lines. If I choose white for a VectorLine, it's dim because of the semi-transparent gray window background.

    If I can re-order when GUI and Vectrosity are rendered, I can overcome this.
     
  35. amw157

    amw157

    Joined:
    Jun 11, 2012
    Posts:
    6
    I tried calling SetVectorCamDepth, but the compiler told me it was not a valid method. Could I have the wrong version of Vectrosity?
     
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, unfortunately OnGUI is always drawn on top of everything and this can't be changed. See this post on the previous page about using rendertextures as a workaround.

    It's part of VectorLine, but it won't help with OnGUI I'm afraid.

    --Eric
     
  37. niall_obrien

    niall_obrien

    Joined:
    Dec 18, 2008
    Posts:
    9
    Hi Eric, I'm just wondering how I can achieve a big glow effect similar to the "sprites" in Geometry Wars (see link below) with Vectrosity. The glow examples I've seen so far have been very minor in comparison.

    Also, as seen in the video, there's an underlaying glowing grid below the player and enemies, any idea how something like this can be accomplished within Unity? It seems that it deforms a lot and lights according to the object colours above it.

    Thanks in advance,
    Niall.
     
  38. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Probably that's an image effect, such as the standard glow image effect in Unity (requires Pro).

    --Eric
     
  39. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    853
    Hi Eric,

    don't know if this is something that should be done in Vectrocity or using an outside approach, but could you think of an easy way to draw a grid which isn't shown completely but whose visible portion "moves" from left to right in a scanner kind of way? The grid itself should stay in its place of course.
     
  40. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not quite following how something would move left to right and stay in place at the same time...seems contradictory to me. ;) The easiest way to move something left/right is to pass in a transform when using VectorLine.Draw, and move that transform. You can also move the transform of the grid itself directly, with VectorLine.vectorObject.transform, though that's not really recommended unless you know what you're doing.

    --Eric
     
  41. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    853
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Aha, I see. I'd suggest using SetColors. That way you can use an array of colors, and change the alpha of the appropriate entries in the array over time in order to fade given lines in and out.

    --Eric
     
  43. kdd_9000

    kdd_9000

    Joined:
    Aug 13, 2012
    Posts:
    6
    Hey Eric, I haven't been able to read the whole thread, but I do have a question. I am able to draw multiple lines, but how do I destroy individual lines? When I use the Destroy function for the VectorLine it only destroys the most recently drawn line. Is there a way to destroy any other lines besides the most recent one? Would I have to declare multiple VectorLines or is it possible to make a VectorLines array? I should also mention, I am using C#.
     
    Last edited: Aug 14, 2012
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    VectorLine.Destroy destroys whatever line you pass in, not the most recent one.

    --Eric
     
  45. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    853
    Hi Eric,

    I am running into a strange error which I already got with another asset once - whenever I move the Vectrosity folder out of the Editor folder it places itself into during import, I get the error message that 'WriteAllBytes' is not a member of 'System.IO.File' at lines 466 and 510. Is it really that picky about its location or am I doing something wrong?

    Cheers,
    Thomas
     
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You should not do this. That folder contains LineMaker.js, which is an editor script, and it will only function if it's in the Editor folder.

    --Eric
     
  47. dammian

    dammian

    Joined:
    Mar 18, 2012
    Posts:
    17
    I just bought it today, I have some crazy ideas for my game :)
     
  48. kdd_9000

    kdd_9000

    Joined:
    Aug 13, 2012
    Posts:
    6
    Hm. What I am doing is connecting two transforms with the line. So far I am just declaring one VectorLine. The user clicks one object, then clicks another, then a line is drawn between the points. The user can do this as many times as they want/need. For example if they draw 3 lines and want to delete the 2nd one, how can I do that? Using the Vectorline.Destroy only deletes the 3rd line. Do I need to declare multiple VectorLines for this to work? And if so what would you recommend the best way to do it, since the amount the lines the user draws is up to them.
     
  49. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Cool, post some screenshots when you can. :)

    Yes.

    I'd say use a List, then you can destroy whichever VectorLine in the List is appropriate.

    --Eric
     
  50. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    853
    Sorry for asking another one of those questions, but I like to keep my projects tidied up whenever possible. ;)

    I have a script attached to a GameObject which draws a hexagon around it.

    Code (csharp):
    1.  
    2.     void Start () {
    3.                
    4.         Vector3[] linePoints = { new Vector3(-10, 0, 18), new Vector3(10, 0, 18), new Vector3(20, 0, 0), new Vector3(10, 0, -18), new Vector3(-10, 0, -18), new Vector3(-20, 0, 0), new Vector3 (-10, 0, 18) };
    5.         VectorLine line = new VectorLine("SystemBoundary", linePoints , null, 2f, LineType.Continuous);
    6.         // line.vectorObject.transform.parent = this.transform;
    7.        
    8.         VectorManager.useDraw3D = true;
    9.         VectorManager.ObjectSetup (gameObject, line, Visibility.Dynamic, Brightness.None);
    10.     }
    11.  
    The Vector SystemBoundary object is placed at the top level of my scene hierarchy and moves along with the original GameObject as expected. However, as soon as I try to make it a child of the original GameObject, either by code (see the line in comments) or by manually moving it in the hierarchy, moving around the GameObject makes the Vector object move at double its speed. There will be more than one of these in the scene most of the time, so I'd rather make them a child if that's possible.

    In my current project both objects are unlikely to move, but I'd like to understand why this happens so I can avoid this problem with moving objects further down the road.
     
    Last edited: Aug 15, 2012
Thread Status:
Not open for further replies.