I’ve two objects with a line going from one to the opposite, like this:
I need to create one other line with a begin level on one of many objects and an finish level on the mouse place, nevertheless, nonetheless in entrance of the second object, it’ll appear to be the primary line is filling as much as the place the mouse is.
For instance, I need to join the blue form to the inexperienced form, so I transfer the mouse from one to the opposite. The sport finds the white line closest to the cursor and creates one other line above it that follows my cursor, like this:
The present script is that this. Attracts a line from the supply form to the mouse place, however it does not keep in a single course however as a substitute strikes to the place the mouse goes:
public class SelectionLine : MonoBehaviour {
personal LineRenderer lineRenderer;
personal void Awake() {
lineRenderer = GetComponent<LineRenderer>();
}
personal void Replace() {
if (ShapeSelection.occasion.selectedShape != null && ShapeSelection.occasion.draggingFinger != null) {
var originPosition = ShapeSelection.occasion.selectedShape.remodel.place;
var destinationPosition = ShapeSelection.occasion.draggingFinger.ScreenPosition;
lineRenderer.SetPosition(0, new Vector2(originPosition.x, originPosition.y));
lineRenderer.SetPosition(1, new Vector3(ShapeSelection.occasion.draggingFinger.GetWorldPosition(1f).x, ShapeSelection.occasion.draggingFinger.GetWorldPosition(1f).y, 0));
}
}
}
There isn’t any method (so far as I do know) to set an tackle of a line renderer in Unity, so how can I obtain this?

