Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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. psdev

    psdev

    Joined:
    Feb 11, 2011
    Posts:
    53
    So how does DrawLine3DAuto actually work? i.e. I am getting performance issues? where the line flickers and tries to catch up with how it should draw itself if I have the globe rotating. I assume this is because it is trying to recreate the geometry so the ribbon faces the camera every frame? A square or hexagon shaped tube (although adding more polys) would prevent this... How would you approach this if you need the line to be in the 3D scene (occluded etc) but also look and perform correctly during animation of its parent?

    thanks :)
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Adding geometry for a tube would look wrong and would run slower. There shouldn't be any performance issues; the orbit lines in the orbit demo, for example, use DrawLine3DAuto and there's no flickering or anything. It sounds like you may have more than one thing attempting to control the line movement, creating some conflict. You might consider using a VectorManager object, so that the line object essentially behaves like a standard GameObject but is drawn with Vectrosity.

    With two points, "a" and "b", (a + b) / 2 is the midpoint. You can use that principle to subdivide a few times.

    --Eric
     
  3. psdev

    psdev

    Joined:
    Feb 11, 2011
    Posts:
    53
    Thank you very much for that tip! VectorManager is exactly what I needed. It makes things a whole lot easier, especially if I am parenting lines to other moving objects.
     
  4. psdev

    psdev

    Joined:
    Feb 11, 2011
    Posts:
    53
    Sorry Eric, one more question: Does minDrawIndex and maxDrawIndex work on lines that are made by VectorManager.ObjectSetup ?

    i.e. I'd like to make it appear like the lines are drawing (in 3D, while parented to another object and with polys always facing the camera) and I've successfully used maxDrawIndex with DrawLine3D before, but it doesn't appear to be working in the Update if I try to change that property on the line passed to VectorManager...?
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, VectorManager is built on top of the standard functions.

    I just tested and didn't have any issues. Perhaps you're not actually updating the correct line?

    --Eric
     
  6. tilluigi

    tilluigi

    Joined:
    Mar 15, 2012
    Posts:
    4
    thanks, after a little thinking i was able to find that out myself, its working great (screen attached)!
    i really enjoy the versatility of Vectrosity (that almost kinda rhymes!)

    but that leads to another noob question: how do i enable anti-aliasing for my vectors?
     

    Attached Files:

  7. tilluigi

    tilluigi

    Joined:
    Mar 15, 2012
    Posts:
    4
    ok, i am using the free anti-aliasing trick described and it works with my smoothcolors as well. again, great stuff eric!
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can also turn on anti-aliasing in Unity, although that's not 100% guaranteed to work everywhere and has a performance impact.

    --Eric
     
  9. psdev

    psdev

    Joined:
    Feb 11, 2011
    Posts:
    53
    Sorry but it's not clear to me. If I use:

    VectorManager.ObjectSetup (MyLineNULL, myline, Visibility.Always, Brightness.None, false);

    MyLineNULL ends up being the parent GameObject that the vecrosity line gets created at? And myline is the line that I can modify in the Update? when I modify myline.maxDrawIndex in Update nothing happens - what am I missing?

    thanks for clarifying.
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I modified the Simple3D 2 example script a bit as a test, works fine:

    Code (csharp):
    1. var vectorCube : TextAsset;
    2. var lineMaterial : Material;
    3. private var line : VectorLine;
    4.  
    5. function Start () {
    6.     var cubePoints = Vector.BytesToVector3Array (vectorCube.bytes);
    7.     line = new VectorLine("Cube", cubePoints, Color.white, lineMaterial, 2.0);
    8.     line.maxDrawIndex = 1;
    9.     VectorManager.ObjectSetup (gameObject, line, Visibility.Dynamic, Brightness.None);
    10.     InvokeRepeating("ExtendLine", .25, .25);
    11. }
    12.  
    13. function ExtendLine () {
    14.     line.maxDrawIndex++;
    15. }
    --Eric
     
  11. psdev

    psdev

    Joined:
    Feb 11, 2011
    Posts:
    53
    Thanks, this works for me too now. My problem was that I did not set the maxDrawIndex to 1 in the start to begin with.

    Though I am a little confused and am not sure if there is a bug here though it's likely again to me doing something wrong. Would you check out this simple script and see if there is a bug in Vectrosity? I just create a scene with 5 Empty GameObjects named NULL_Line1 through 5. This draws a 50 segment line. All works fine until you try to change the minDrawIndex or set the maxDrawIndex to something less than it was when Start() executed.

    Running this and hitting the F5 key shows 2 segments (as if the first segment is not erased properly?) instead of moving where the segment is being drawn along the line. Can you test this on your end and tell me what I am doing wrong or if there is a refresh command or something that gets minDrawIndex to work, or maxDrawIndex to work when set to something less than it already is?

    thanks for your help with this!



    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class TestLineDrawingScript: MonoBehaviour
    5. {
    6.     private VectorLine myline;
    7.     private Material myMat;
    8.    
    9.     private GameObject Line1;
    10.     private GameObject Line2;
    11.     private GameObject Line3;
    12.     private GameObject Line4;
    13.     private GameObject Line5;
    14.    
    15.     private const int MAX_SEGMENTS = 50;
    16.    
    17.     private GameObject MyLineNULL;
    18.  
    19.     private Vector3[] linePoints;
    20.    
    21.     // Use this for initialization
    22.     void Start ()
    23.     {
    24.         Line1 = GameObject.Find("NULL_Line1");
    25.         Line2 = GameObject.Find("NULL_Line2");
    26.         Line3 = GameObject.Find("NULL_Line3");
    27.         Line4 = GameObject.Find("NULL_Line4");
    28.         Line5 = GameObject.Find("NULL_Line5");
    29.  
    30.         myMat = (Material)Resources.Load("MyMat");
    31.  
    32.         myline = new VectorLine("MyLine",new Vector3[MAX_SEGMENTS+1], myMat, 5.0f, LineType.Continuous, Joins.Weld);       
    33.    
    34.         // Set the points of the array linePoints at the positions
    35.         linePoints = new Vector3[] {Line1.transform.position, Line2.transform.position,  Line3.transform.position, Line4.transform.position, Line5.transform.position};
    36.        
    37.         Vector.MakeSplineInLine (myline, linePoints, MAX_SEGMENTS);
    38.  
    39.         MyLineNULL = new GameObject("myLineNULL");
    40.  
    41.         VectorManager.useDrawLine3D = true;
    42.        
    43.         myline.minDrawIndex = 10;
    44.         myline.maxDrawIndex = 20;
    45.         VectorManager.ObjectSetup(MyLineNULL, myline, Visibility.Always, Brightness.None, false);
    46.  
    47.     }
    48.  
    49.     // Update is called once per frame
    50.     void Update ()
    51.     {
    52.         if(Input.GetKeyDown(KeyCode.F5))
    53.         {
    54.             myline.minDrawIndex = 30;
    55.             myline.maxDrawIndex = 40;
    56.         }
    57.     }
    58. }
     
  12. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Min and maxDrawIndex won't remove segments that are already drawn; they are just an optimization so that, for example, the entire line doesn't have to be recomputed if you're just adding some points at the end and not changing any of the earlier points. See the DrawLinesMouse example script. If you want to remove segments, you can set the relevant points to Vector3.zero and redraw the line.

    --Eric
     
  13. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    So, speaking of which... I've just started looking into the best way to do this, and have not gone far... If I had a HUD being drawn by Vectrocity, and wanted to toggle the whole shebang on and off... Is there and easy shortcut? Having done little to no research except ask?
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, you can use VectorLine.active. If the HUD is made of more than one VectorLine, then you'd toggle .active for each one. Another possibility is to just disable the vector camera, if the HUD is the only thing being drawn by Vectrosity. In this case you can get a reference to the vector camera by doing "var cam = Vector.SetCamera();" at the start and do "cam.enabled = false/true".

    --Eric
     
  15. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Thanks for the tips!

    I'll try the camera trick, and I'll wrap where I'm updating the HUD in a bool as well, so it won't be calculating in the BG.
     
  16. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    aah!

    I made the same mistake as psdev.
     
  17. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    so if I wanted to change the drawmouse sample scene so that I could hold down the right mouse button and the lines would be erased from the last point drawn to the first, I would cycle through the linepoints arrays and set each point to vector.zero?
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yep, that should work.

    --Eric
     
  19. MentalFish

    MentalFish

    Joined:
    Nov 2, 2005
    Posts:
    282
    Quick question. How do I go about parenting a 3D line to a GameObject?
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    VectorLine.vectorObject is a reference to the line's GameObject, so you can use that.

    --Eric
     
  21. MentalFish

    MentalFish

    Joined:
    Nov 2, 2005
    Posts:
    282
    Thanks a bunch, just what I needed.
     
  22. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    hey guys, this may relate to my last question, but I'm using code similar to mouse draw sample code except it allows drawing multiple lines as separate vector objects. I've been pondering if there is an easy way to create an erase tool? any thoughts?
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Not really an easy way that I can think of. Unless you have a solid-colored background, in which case just make a line the same color as the background and have it draw on top of the other lines. It's not really erasing, of course, but it would look like it. Otherwise I think you'd have to scan through the points in the line arrays and compare them to the current mouse position, and zero out the closest match if it's within a certain distance.

    --Eric
     
  24. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    both of those seem like pretty good ideas, thanks Eric, except those erased areas won't be drawable again...perhaps drawing every new line at a z distance a small bit closer to the camera than the last?
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That sounds like it would work; you can use VectorLine.depth for that.

    --Eric
     
  26. MentalFish

    MentalFish

    Joined:
    Nov 2, 2005
    Posts:
    282
    I thought I had a Vectrosity issue but it turns out to be something else.

    I came across a C# implementation of a Delauney triangulation solution which works like a treat (Unity editor view on the left), but as you can see in the image to the right it goes all wonky on the lower parts of the triangulation while running on an iPad:


    My gut is telling me it has something to do with decimal precision? Care to take a look?

    http://dl.dropbox.com/u/1258056/UnityForum/DelaunayTest.unitypackage

    Update: it works on Android but no go on iPod, so it must be an iOS/Xcode issue:


    Solution, use different Delaunay implementation: http://code.google.com/p/jdt/downloads/list

    Works on iOS:


    Isn't talking to oneself the first sign of insanity? :)
     
    Last edited: Mar 25, 2012
  27. mohamed20

    mohamed20

    Joined:
    Mar 25, 2012
    Posts:
    5
    Good evening, eg you help me I have a final project study I'm working on unity 3d I like to know how to draw simple shapes (line, rectangle, round ...) help me please and give me solutions.
     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That's pretty weird. Glad you got it working anyway.

    Vectrosity does that nicely. ;)

    --Eric
     
  29. mohamed20

    mohamed20

    Joined:
    Mar 25, 2012
    Posts:
    5
    Help me plz §§§§
     
  30. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    http://www.starscenesoftware.com/vectrosity.html Scroll to the bottom, and click on one of the yellow buttons. I'm happy to give support, but I'm sure you understand that you must be a customer first.

    --Eric
     
  31. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    Hey Eric, you support is great, I have what is probably a simple question.

    I'm drawing a line, at each point on the line a rigid body is instantiated that samples its position and draws a new line behind it. So my draw calls end up growing very large very fast.

    Any ideas on how to batch these draw calls? Seems to be one per vector object?
     
  32. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Maybe one big line, and have each rigidbody draw into the line with a different index? So points 0-499 would belong to rigidbody 1, rigidbody 2 would have points 500-999, etc.

    --Eric
     
  33. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    Hi,

    I`m not a coder, so even though your tool looks interesting to me, I can`t use it. The only way I can use your tool is if vectrosity would be integrated with Playmaker. After I`ve seen your examples I had the feeling that Vectrosity openes so many possibilities, but not for me. :(
    Having Vectrosity-Playmaker actions, things will be a bit different. I think this will give me the possibility to draw lines at runtime, change the collors and thicknes according to the gameplay, changing them from dotted lines to continuos lines, etc.
    Do you think is possible to develop/integrate Vectrosity and Playmaker for users like me?
    Thank in advance for your answer.
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I don't own Playmaker, so I doubt it will happen. I'd strongly suggest learning to code. By nature, "no-coding" tools are quite limited (this being a prime example--you can't use third party utilities without someone doing extra development). I'm not against them...I think they have their place, and are useful in some circumstances, but in the end they're no substitute for code. I started using Unity after 9 years in graphic design, so no point playing the "but I'm an artist" card. ;)

    (By the way, this isn't an invitation for a general debate on no-coding tools...that's been done to death elsewhere. Vectrosity-only posts here, thanks. :) )

    --Eric
     
  35. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    Well, it`s your product, and you have all the rights to decide who are your target clients.
    Anyway, thanks for the strong suggestion.
     
  36. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    Hey

    I bought vectrosity via the asset store. It's really useful, but I can't work out how to get mesh rendering working.

    Here's what I have: a script attached to an object with a mesh imported from a 3D package. I've dragged the mesh reference and the material onto the appropriate field in the script using the editor.

    Code (csharp):
    1.  
    2. public var lineMaterial : Material; //reference set in visual editor
    3. public var mesh : Mesh; //reference set in visual editor
    4. private var wireframe:VectorLine;
    5.  
    6. function Start () {
    7.     var tempArray:Vector3[] = new Vector3[mesh.vertexCount];
    8.     wireframe = new VectorLine("wireframe", tempArray, lineMaterial, 32.0, LineType.Discrete, Joins.Weld);
    9.     Vector.MakeWireframeInLine(wireframe, mesh);
    10. }
    11.  
    12. function Update () {
    13.     Vector.MakeWireframeInLine(wireframe, mesh);
    14.     Vector.DrawLine(wireframe);
    15. }
    16.  
    17.  
    Basically this yields no errors but it also doesn't seem to draw anything. What am I doing wrong?
     
  37. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    MakeWireframeInLine should be done once, not every frame in Update.

    Code (csharp):
    1. var mesh : Mesh;
    2.  
    3. function Start () {
    4.     var line = new VectorLine ("Wireframe", new Vector3[2], null, 2.0);
    5.     Vector.MakeWireframeInLine (line, mesh);
    6.     Vector.DrawLine (line);
    7. }
    Other than that, make sure the camera would be able to see mesh, since Vector3 points are in world space.

    --Eric
     
  38. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    Ok, that almost works. But this is how it looks when I'm rendering a simple cube. (Cube looks fine using the inbuilt mesh renderer)



    and here's how it looks using Drawline3D (I'd rather use 2D if possible, I'm shooting for a retro graphics look)

     
    Last edited: Mar 27, 2012
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Use a thinner line width, and/or use Joins.None instead of Joins.Weld.

    --Eric
     
  40. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    Yep, weld still doesn't weld in a convincing way.
     
  41. Dumpen

    Dumpen

    Joined:
    Mar 27, 2012
    Posts:
    2
    I have a problem with my line not being transparent at times.

    It seems to occur at random.

    How it should look:


    How it (sometimes look):


    Here is how I am drawing my lines:
    Code (csharp):
    1. Vector.DestroyLine(ref trajectory);
    2.        
    3. trajectory = new VectorLine("Trajectory", segments, material, 12f, LineType.Continuous);
    4.        
    5. Vector.SetTextureScale(trajectory, 1.0f);
    6. Vector.DrawLine3D(trajectory);
    Trajectory is a VectorLine, segments is a array of Vector3 positions while material is a UnitAlpha shader from the demo with the texture dot2 (The same material as DotLine2 used in the Path scene)
     
    Last edited: Mar 27, 2012
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I would guess that's the result of not using the right shader/material. I can't think of anything that would cause that in Vectrosity. One thing though, if you're doing that DestroyLine/making a new VectorLine a lot, I would recommend not doing that, and just making the line once.

    --Eric
     
  43. Dumpen

    Dumpen

    Joined:
    Mar 27, 2012
    Posts:
    2
    Alright, ill take a look at my material instead. Thought I would give it a shot and ask here first, thinking you might had experienced it before :)

    I am only drawing the line once, then when the user changes position the segments change and I draw it again.
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sorry, that's a new one. :)

    --Eric
     
  45. Clockworkservant

    Clockworkservant

    Joined:
    Nov 15, 2010
    Posts:
    7
    Hi all....

    I'm relatively new to using Vectrosity (nice work, Eric, it seems very robust and easy to use). I have the basics up and running nicely, but now I'm trying to apply it to a more complicated situation.

    In the scene I'm working on, the main camera has an ambient animation on it (it sways around a bit as a character walks), but I have a problem with the texture on the line "swimming" around a bit as the camera moves. Basically, I'm using SetTextureScale to force a 1.0 aspect, but as the camera moves, the texture slides around a bit on the 3D line which is drawn.

    The script I wrote is this:

    Code (csharp):
    1. #pragma strict
    2.  
    3. var myMat:Material;
    4. var line : VectorLine;
    5. var textureSize : int;
    6. var anchors : Vector3[];
    7. // var camObject : Transform;
    8.  
    9. function Start() {
    10.    
    11.     for (var n=0; n < anchors.Length; ++n) {
    12.         anchors[n] = GameObject.Find("Chainlink"+(n+1)).transform.position;
    13.         }
    14.    
    15.     line = new VectorLine("Line", anchors, myMat, textureSize, LineType.Continuous);
    16.  
    17.     Vector.SetTextureScale (line, 1.0);
    18.     Vector.DrawLine3D(line);
    19.  
    20. }
    21.  
    22. function LateUpdate() {
    23.     for (var n=0; n < anchors.Length; ++n) {
    24.         anchors[n] = GameObject.Find("Chainlink"+(n+1)).transform.position;
    25.     }
    26.    
    27.     Vector.SetTextureScale (line, 1.0);
    28.     Vector.DrawLine3D(line);
    29. }
    Probably there are some inefficiencies in there, as I'm still trying to learn the syntax (there are some redundancies, but I don't think that affects the problem).

    My only thought is that I could use the transform of the camera to somehow to compensate for its movement (or something). I can't quite wrap my head around what I should attempt to solve this. Hopefully this all makes sense.

    The reason that I'm updating the line in LateUpdate() is that I will eventually be moving some of the anchor points around dynamically, and need the line to update accordingly.

    Cheers in advance for any help you could offer.
     
    Last edited: Mar 28, 2012
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I would guess the sliding is because the line is changing length, and SetTextureScale makes sure the texture always stays proportional regardless of the line's length. Maybe you should just do SetTextureScale once in Start, and not in LateUpdate? I'm not sure what effect you're going for.

    --Eric
     
  47. Clockworkservant

    Clockworkservant

    Joined:
    Nov 15, 2010
    Posts:
    7
    I guess I could explained things a little better. Using the above script, I've set up 4 points, between which I'm drawing the continuous line. The line uses a chain-link texture.

    In the final game, the plan is to have the middle two points move around to create the illusion that something heavy is hanging from the chain. But currently... even when no points are being moved, the texture slides around. To be more precise, the mapping appears locked at the beginning of the line, but looks to scale slightly in and out across the length of the line as the camera animates.

    If I remove the animation from the camera, everything works perfectly, so it's at least related to that in some way.
     
    Last edited: Mar 28, 2012
  48. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Is the camera animation making the length of the line vary a little? What happens if you just set the texture scale once?

    --Eric
     
  49. Clockworkservant

    Clockworkservant

    Joined:
    Nov 15, 2010
    Posts:
    7
    The camera isn't affecting the line, in any way that I can see. The points of the line aren't moving.

    Strangely, when I remove the SetTextureScale from LateUpdate, the texture behaves properly -- no swimming around. The only problem is, without that line in there, when I move a point, it will stretch incorrectly (ie. it won't hold it's 1.0 texture aspect).

    Edit: it's the same issue if I use Vector.DrawLine3DAuto(); to update the line, instead of using Vector.DrawLine3D in LateUpdate()

    For example, this code produces the same effect. No swimming around, but the line texture stretches when I'm pulling around points in the line:


    Code (csharp):
    1. function Start() {
    2.    
    3.     for (var n=0; n < anchors.Length; ++n) {
    4.         anchors[n] = GameObject.Find("Chainlink"+(n+1)).transform.position;
    5.         }
    6.    
    7.     line = new VectorLine("Line", anchors, myMat, textureSize, LineType.Continuous);
    8.  
    9.     Vector.SetTextureScale (line, 1.0);
    10.     Vector.DrawLine3DAuto(line);
    11.  
    12. }
    13.  
    14. function LateUpdate() {
    15.     for (var n=0; n < anchors.Length; ++n)
    16.         anchors[n] = GameObject.Find("Chainlink"+(n+1)).transform.position;
    17. }
    If I then add Vector.SetTextureScale (line, 1.0); into the LateUpdate(), I get the swimming around again.
     
    Last edited: Mar 28, 2012
  50. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I didn't see this before:

    That is indeed how it works; the mapping is locked at the beginning, and scales the UVs so that the texture is always the desired aspect. If the texture is changing, that means the length of the line is changing. Maybe only slightly, but enough that the scaling would be visible. It seems to me that you shouldn't set the texture scale in Update, only once when the line is created and again when the points are moved.

    --Eric
     
Thread Status:
Not open for further replies.