buttt you could always just use a raycast from one object to the other - not sure how you were going to use that? - but then you could use a debug code to tell it to draw a line (just a simple one pixel line is all I know) along the rays path. I sure couldn’t tell you how to code that
function Update () {
var forward : Vector3 = transform.TransformDirection(Vector3.forward) * 10;
Debug.DrawRay (transform.position, forward, Color.green);
}
But this only works in game, if you want editor.
Then check the Gizmo.Drawline
var target : Transform;
function OnDrawGizmosSelected () {
if(target != null) {
// Draws a blue line from this transform to the target
Gizmos.color = Color.blue;
Gizmos.DrawLine (transform.position, target.position);
}
}
And click the object when you want to see the linie.
i succeed in draw a line start from one of my game objects but the line go down not straight , i need the line to be gone from one object to another also in line render , how?
I recently got started playing with unity and had a similar need. I ended up using this:
lineRenderer.SetPosition(0, new Vector3(objectOne.transform.position.x,objectOne.transform.position.y,objectOne.transform.position.z));
lineRenderer.SetPosition(1, new Vector3(objectTwo.transform.position.x,objectTwo.transform.position.y,objectTwo.transform.position.z));