Draw an Arrow on the Screen

Hi,

I would like to draw an arrow on the screen, from one coordinate to another on the screen, so the coordinated are the screen coordinates (2D) rather that in the 3D world.
This will change depending on where the player’s finger is on the screen.

How can I make an arrow appear from one coordinate to another, preferably “dynamic”, so the arrow can be longer without it being stretched?

Thanks!

Here is a script that will position, rotate, and scale an object to extend between two game objects dynamically. Its current form uses the ‘y’ of the object, so the top and bottom are at the two specified positions. try it with build-in cylinder, built-in cube, or a 1 unit, vertical plane from the CreatePlane editor script. It only scales the ‘Y’ values, so the x, and z scaling can be set as appropriate for visual look. In order for the arrow to not look stretched, make the arrow head a separate object. Place it at the end point, rotate it, but don’t scale it.

pragma strict

var pos1 : Vector3;
var pos2 : Vector3;
var objectHeight = 2.0;  // 2.0 for a cylinder, 1.0 for a cube

function Update () {

	if (Input.GetMouseButtonDown(0)) {
		pos1 = Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane + 0.5);
    	pos1 = Camera.main.ScreenToWorldPoint(pos1); 
    	pos2 = pos1;
    
	}
	
	if (Input.GetMouseButton(0)) {
		pos2 = Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane + 0.5);
    	pos2 = Camera.main.ScreenToWorldPoint(pos2); 
    
	}
	
	if (pos2 != pos1) {
		var v3 = pos2 - pos1;
    	transform.position = pos1 + (v3) / 2.0;
    	transform.localScale.y = v3.magnitude/2.0;
    	transform.rotation = Quaternion.FromToRotation(Vector3.up, v3);
    }
}