Line being drawn from point A to B
Hello, after pressing command was activated I want to draw a line, which appears from vector2(0,0) to vector2(10,10). Sprite should be tiling. My sprite size is 1x3. But when i put it in material i becomes 1x1. Also which animation should I use?
Answer by WolverineLight · May 27 at 02:55 PM
"Hello, after pressing command was activated I want to draw a line, which appears from vector2(0,0) to vector2(10,10)."
One way to approach this is by using a line renderer. You can also use GL or GUI.Debug.DrawLine.
Here is some code that may help (using LineRenderer) (source):
LineRenderer l = gameObject.AddComponent<LineRenderer>();
List<Vector3> pos = new List<Vector3>();
pos.Add(new Vector3(0, 0));
pos.Add(new Vector3(10, 10));
l.startWidth = 1f;
l.endWidth = 1f;
l.SetPositions(pos.ToArray());
l.useWorldSpace = true;
I hope this helps.
In order to help you furhter, can you share some code or more information about the project?
Regarding the sprite and/or the animation, could you also provide more information?
Answer by sMotiejus · May 29 at 10:46 AM
Hi @WolverineLight, I have empty class which is frame for Instatiated points to be located. After pressing two points I want the rope to be drawn from one side to other. The problem that I have right now is that despite line being Start: (0,0,0) and (1000,0,0) Its still not completely aligned to X, its slightly going up .
Do you have any ideas why it can be happening? My sprite is:
Forgot to add that Instanciated points are childs of that Empty class.