- Home /
Best Answer
Answer by shaibam · Jul 07, 2015 at 08:49 AM
Found it: Create EmptObject and attach Effects->LineRenderer.
then Attach the Following Script to the new Object
using UnityEngine;
using System.Collections;
public class DrawLine : MonoBehaviour {
public GameObject[] targets; // the objects to draw the line between
// Use this for initialization
private LineRenderer l;
void Start () {
l =this.GetComponent<LineRenderer>();
Vector2 p1 = targets [0].transform.position;
l.SetPosition (0, p1);
}
// Update is called once per frame
void FixedUpdate () {
Vector2 p1 = targets [0].transform.position;
Vector2 p2 = targets [1].transform.position;
Vector2 lineVector = p2 - p1;
l.SetPosition (0, p1);
l.SetPosition (1, p2);
}
}
Answer by HarshadK · Jul 07, 2015 at 07:29 AM
For the rope draw a line using Line Renderer with two points of line as anchor and connectedAnchor from the DistantJoint2D. You can set the material for this line renderer to the material you want.
Thank you. can you give me a little more explenation about connecting the Line Renderer to the elements?