Unity Community


Page 117 of 121 FirstFirst ... 1767107115116117118119 ... LastLast
Results 2,321 to 2,340 of 2411

  1. Posts
    2
    Hey Eric,

    I just purchased your software hoping to draw a vector circle centered at the mouse position and that scaled over time from the center. Currently, I'm creating an object that creates and draws the circle itself so that I can scale the object for scaling purposes, but I'm running into two issues.

    One: The circle is not centered on mouse (or in my game, the object's position, converted to a screen point) when the mouse or object moves away from the center of the screen

    Two: When I scale the object, the circle scales and moves away from the mouse point. I assume that the circle is being scaled from one of the corners and not the center?

    Overall, I'm pretty new to Unity and this has been frustrating me for a few hours. Any help would be appreciated.

    Potentially relevant information: I have two cameras set-up and they are both 2D Toolkit cameras. One is culling everything except for a GUI layer and the other is just for GUI. I am also using PoolManager 5 for spawn pools.

    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3. using PathologicalGames;
    4. using Vectrosity;
    5.  
    6. public class CircleScript : MonoBehaviour
    7. {
    8.     /* public */
    9.     public float radius,
    10.                  lineWidth;
    11.     public int vectorPoints;
    12.     /* private */
    13.     private VectorLine myCircle;
    14.  
    15.     void Awake()
    16.     {
    17.         VectorLine.SetCamera(Camera.main, CameraClearFlags.Depth, true);
    18.     }
    19.  
    20.     // use this for spawn
    21.     void OnSpawned()
    22.     {
    23.         Vector2[] linePoints = new Vector2[vectorPoints * 2];
    24.         myCircle = new VectorLine("MyCircle", linePoints, null, 2.0f, LineType.Discrete);
    25.         myCircle.drawTransform = transform;
    26.         myCircle.MakeCircle(Camera.main.WorldToScreenPoint(transform.position), radius, vectorPoints);
    27.         myCircle.Draw();
    28.         InvokeRepeating("ChangeScale", 0.01f, 0.02f);
    29.     }
    30.  
    31.     void OnDespawned()
    32.     {
    33.         VectorLine.Destroy(ref myCircle);
    34.     }
    35.  
    36.     void ChangeScale()
    37.     {
    38.         //Vector3 s = transform.localScale * .01f;
    39.         transform.localScale *= 1.01f;
    40.         transform.position.Scale(transform.localScale);
    41.         myCircle.Draw();
    42.     }
    43.  
    44.    
    45. }

  2. Volunteer Moderator
    Posts
    23,729
    Hi, I'd suggest making the circle at the origin, then using WorldToScreenPoint to move the transform to the desired location instead. That way it will scale from the center, and moving the transform will also move the circle to the correct place. Depending on how you have things set up, you may want to use a second transform as the .drawTransform.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  3. Posts
    407
    Quote Originally Posted by Eric5h5 View Post
    You can see what's included on the asset store page: https://www.assetstore.unity3d.com/#/content/82. I just verified that there's no problem and everything that you see there imports fine, including the docs.

    @aureliocalegari: I expect you're running into floating point limitations; a view distance of 160K will cause problems aside from Vectrosity. Typically you don't want to exceed 10K if you want to maintain a decent amount of precision. There are a fair number of topics covering this issue, so you can get some ideas for different techniques; typically some kind of subdivided space. There's a bit here (the "Kraken" sidebar in the "Abort" section) about what Kerbal Space Program did (which uses Vectrosity by the way).

    --Eric
    Sorry for the confusion. I didn't actually purchase from the Unity Asset Store, but from your Starscene Asset store here:
    http://starscenesoftware.com/store.html

    After I purchased it, you e-mailed me a link, to which I'm suppose to be able to receive future updates, but the link is dead when I click on it in my e-mail.

  4. Volunteer Moderator
    Posts
    23,729
    If you bought from my site, then you get a zip file, which contains all the packages and documentation. If you bought recently, the link should not be dead; try clicking it again (maybe the web site was briefly down?)...let me know if you're still having problems. If you bought a long time ago, the old links are no longer valid after I updated my site last year, so you can use the contact form on my site to request a new link.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  5. Posts
    61
    Hi Eric,

    Not sure if it's by design or not, but when I create two vector lines using the same position array, the one modifies the other when I access each individual line's points2. e.g.:

    Code:  
    1. Vector2[] points = new Vector2[2];
    2. points[0] = GetPoint.Screen(transform.position);
    3. points[1] = points[0];
    4.  
    5. vectorLine = VectorLine.SetLine(lineColor, points);
    6. lineHeadCW = VectorLine.SetLine(lineColor, points);
    7.  
    8. ------
    9.  
    10. vectorLine.points2[0] = point0Pos;
    11. vectorLine.points2[1] = point1Pos;
    12.  
    13. lineHeadCW.points2[0] = point0Pos;
    14. lineHeadCW.points2[1] = (Vector3)point0Pos + Quaternion.AngleAxis(45f, Vector3.forward) * direction * 10;

    The lineHeadCW.points2[1] line affects the vectorLine. If I duplicate the points array at the beginning and apply it to lineHeadCW, then it works as expected. Is this another of my misinterpretations?

  6. Volunteer Moderator
    Posts
    23,729
    Arrays are by reference, so yep, that's expected behavior.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  7. Posts
    61
    Ah, excellent. I just added points for each instead of defining arrays. Any luck with the GetPointAtPosition()?


  8. Posts
    407
    Quote Originally Posted by Eric5h5 View Post
    If you bought from my site, then you get a zip file, which contains all the packages and documentation. If you bought recently, the link should not be dead; try clicking it again (maybe the web site was briefly down?)...let me know if you're still having problems. If you bought a long time ago, the old links are no longer valid after I updated my site last year, so you can use the contact form on my site to request a new link.

    --Eric
    We bought it about 2 years ago, so that's probably the issue. We'll fill out the contact form. Thanks.

  9. Volunteer Moderator
    Posts
    23,729
    Quote Originally Posted by gumboots View Post
    Ah, excellent. I just added points for each instead of defining arrays. Any luck with the GetPointAtPosition()?
    Arrays are fine, they just need to be unique arrays for each line. The GetPoint thing will be in the next version.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  10. Posts
    12
    This is a great looking asset!! I've been playing around with it and following through the Documentation (which is extremely thorough!) and it is definitely going to become a staple in the applications I create.

    However I'm currently building an application that requires heavy use of NGUI and I'm having trouble integrating your vector lines with it.
    I can draw lines, however, the scale and or position do not correlate with my NGUI objects.

    I have found a few old posts talking about using NGUI and Vectrosity together however I have not been able to generate any working code from them. The example below seems to be trying to accomplish what I would like, however Draw3DAuto is not liking the argument assigned.
    For example:
    Code:  
    1. var uiElement1 = // Some Element, lets say texture
    2. var uiElement2 = // Some Other Element lets say texture
    3. var uiElementContainer = // Some panel which contains all ui elements
    4. var guiCamera = GetComponentInChildren<Camera>();
    5. var transformedPosition1 = guiCamera.WorldToScreenPoint(uiElement1.transform.position);
    6. var transformedPosition2 = guiCamera.WorldToScreenPoint(uiElement2.transform.position);
    7. var line = VectorLine.SetLine(Color.red, transformedPosition1, transformedPosition2);
    8. line.vectorObject.transform.parent = uiElement1.transform; // Add under uiElement 1 to clip when it moves off the panel
    9. line.Draw3DAuto(uiElementContainer.transform);
    10. line.lineWidth = 2;

    Is there a simple way to ensure any lines I generate are using the same scale and world or screen space that NGUI is using?
    Does anyone have any tip or suggestions on using these two assets together. Anything would be greatly appreciated.
    Last edited by mplaczek; 03-10-2014 at 02:54 AM.

  11. Volunteer Moderator
    Posts
    23,729
    Draw3DAuto doesn't work like that anymore; see the included upgrade guide for how to use transforms with lines in Vectrosity 3.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  12. Location
    Greece
    Posts
    10

    SetRay(world space) vs SetRay3D

    Hi,
    complete newbie to vectrocity
    I understand that SetRay renders over everything in the scene in contrast to SetRay3D.
    But the 3D version also updates its perspective when I move the camera whereas SetRay (with Vector3 parameters in world space) does not.
    Its like SetRay uses the worldspace projection of the camera it found in the first frame or so.
    The same happens when I use Vector3 with SetLine in World space.

    What is the fundamental difference between these two functions, why is the SetRay using world space coordinates not getting the current camera matrix?

    Thanks
    Dimi

  13. Volunteer Moderator
    Posts
    23,729
    SetRay (and the Draw function) renders 2D lines in an overlay. You can use both screen space coordinates or world coordinates, but in both cases the lines are rendered once as a 2D overlay and then not updated unless you specifically tell them to update. This is good for lines that don't need to be updated often (or at all) because then they take no extra CPU time.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  14. Location
    Greece
    Posts
    10
    Thanks

    Quote Originally Posted by Eric5h5 View Post
    SetRay (and the Draw function) renders 2D lines in an overlay. You can use both screen space coordinates or world coordinates, but in both cases the lines are rendered once as a 2D overlay and then not updated unless you specifically tell them to update. This is good for lines that don't need to be updated often (or at all) because then they take no extra CPU time.

    --Eric


  15. Location
    Brisbane, Australia
    Posts
    160
    How do you delete a line created with Draw3D?

  16. Volunteer Moderator
    Posts
    23,729
    Use VectorLine.Destroy().

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  17. Location
    Brisbane, Australia
    Posts
    160
    Quote Originally Posted by Eric5h5 View Post
    Use VectorLine.Destroy().

    --Eric
    Thx for reply. I am not sure how that works for my code. See below for example code.

    I just want to ensure I am following best practice for the VectorLine class.

    Is this the best way to Destroy the gameobject that Draw3D creates?

    Code:  
    1.                 // Create VectorLine
    2.                 _vLine1 = new VectorLine(parm, new Vector3[] { GameObject.Find("Player").transform.position, targetPos }, dashedLineMaterial, 4.0f);
    3.  
    4.                 // Draw the line
    5.                 _vLine1.Draw3D();
    6.  
    7.                  // Deactivate line
    8.                 _vLine1.active = false;
    9.  
    10.                // I could do, to destroy
    11.                _vLine1.vectorObject.Destroy();

  18. Volunteer Moderator
    Posts
    23,729
    See "Removing Vectorlines" in the docs, page 17. Do not use vectorObject.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  19. Location
    Brisbane, Australia
    Posts
    160
    Thank you. That's exactly what I was looking for. (My apologies for not reading documentation)


  20. Location
    Greece
    Posts
    10

    Lines getting bigger as camera moves and Select with Ray

    Hi
    some additional newbie questions. I waded through almost all of the Documentation (missing still 8 pg until the end , very nicely written by the way congrats). Unfortunately I havent found a solution to something I noticed almost from the beginning.

    1) When I create a Vector3 /Draw3D line and set a pixel width say 4 or even 2, I notice that the line get thinner/bigger as i move the camera near/far. This is really obvious and I dont understand why the scaling happens.

    2) Is there a way to select lines using rays and world space positions instead of just mouse position? Say I have this character and I want him to select a line (I have his world space position/direction). Or in case I have a 3D tracking device. I imagine a interface like the on we user for Physics.Raycast.

    Thanks
    Dimi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •