Closed fordx closed 7 years ago
Hi fordx,
Do you mean rendering polygon lines?
Vectrosity does a great jobs at that: https://www.assetstore.unity3d.com/en/#!/content/82 Other resources here: http://answers.unity3d.com/questions/173464/draw-a-line-in-game-view.html And here: http://docs.unity3d.com/Manual/class-LineRenderer.html
Jonathan
jderrough, Thank you for your time and consideration. sry my English I tried to use the "RenderLine". but dont work in your map, but when I create 2 gamesobject works Attached follows the class that tries to connect (rendering polygon lines) the 2 markers i am using your project. //--------------------------------- using UnityEngine; using System.Collections;
public class Drawline : MonoBehaviour {
private LineRenderer LineRenderer;
private float counter;
private float dist;
public Transform origin;
public Transform destination;
public float lineDrawSpeed = 6f;
// Use this for initialization
void Start () {
LineRenderer = GetComponent<LineRenderer>();
LineRenderer.SetPosition(0, origin.position);
LineRenderer.SetWidth(.45f, .45f);
dist = Vector3.Distance(origin.position, destination.position);
}
// Update is called once per frame
void Update () {
if (counter < dist) {
counter += .1f / lineDrawSpeed;
float x = Mathf.Lerp(0, dist, counter);
Vector3 pointA = origin.position;
Vector3 pointB = destination.position;
Vector3 pointAlongLine = x * Vector3.Normalize(pointB - pointA) + pointA;
LineRenderer.SetPosition(1, pointAlongLine);
}
}
} //------------------------------
in your class "TestMap", START().
GameObject RenderLine = Instantiate(Resources.Load("LineRenderer", typeof(GameObject))) as GameObject;
RenderLine.transform.parent = map.transform;
Drawline DrawlineScript = RenderLine.GetComponent("Drawline") as Drawline;
DrawlineScript.origin = GameObject.Find("b").transform;
DrawlineScript.destination = GameObject.Find("a").transform;
Debug.Log("b - Origin: " + DrawlineScript.origin.transform.position + "a - Destination: " + DrawlineScript.destination.transform.position);
Debug.DrawLine(DrawlineScript.origin.transform.position, DrawlineScript.destination.transform.position, Color.red);
Anyone have ans for this question,i need to connect two markers?
it is possible create edges between the markers?