- Home /
Directional Indicator UI - Like a Compass - Shows object's Vector
I need to display UI elements to reflect a vector or spin direction placed on an object.
Basically this is a sphere controller, where user presses button 0 the UI appears centered on that exact spot.
As the mouse is dragged in a direction from that point a line or anything like it is drawn dynamically indicating the direction of force being placed on the sphere. angle and magnitude.
Basically I just need to draw a line connecting the the press point to the current drag point... here's a pic! alt text
I'm somewhat new to Unity but I have spent the day researching it... No go. I have no idea how to get this working.
thanks
Answer by Bluk · Aug 04, 2012 at 05:49 PM
Hi,
So if I correctly understood your post, what you need to do is:
Get the mouse position when you press "0" that wil be your origin point
Draw a line each Update() using a line Renderer. (http://docs.unity3d.com/Documentation/Components/class-LineRenderer.html) between origin and current mouse position.
Stop drawing on click or whatever other event you want.
Do whatever you want with the origin and last length of the line :)
Answer by I9ball · Aug 04, 2012 at 10:01 PM
Sorry, by Press button 0 i meant left mouse button :P.
I think you have the idea:
Press : Record Mouse Position, is start point of draw line drag: each update record current Mouse Position Draw line from start point to curr mouse position. release: stops draw operation resets variables.
Optimally it should be rendered in the screen plane like a GUI.
When the start point is set I would also like to place a background reference graphic: the concentric circles in the image above.
thanks for the help.