I have the following code to make a sprite rotate around a character in 2D towards the mouse pointer, however, I’d like to know how to increase the sprite renderer size so that it stretches from the player to the mouse pointer. At present, when I increase size, it obviously increases the size on both ends of the Sprite Renderer. I’d like to only increase the size on one side. I think the only way to do this is to move the sprite’s position relative to the size increase and parent object, which I’m having difficult time with.
Also, the reason I’m not using LineRenderer is becasue I have a 2D collider on the sprite, otherwise I would have and the problem would have been solved hours ago.
float angle;
Vector3 mousePos = Input.mousePosition;
Vector3 objectPos = Camera.main.WorldToScreenPoint(this.transform.position);
mousePos.x = mousePos.x - objectPos.x;
mousePos.y = mousePos.y - objectPos.y;
angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
if(this.transform.tag == "Laser")
{
mousePos = Input.mousePosition;
Vector3 worldPos = worldCamera.ScreenToWorldPoint(mousePos);
float x = worldPos.x;
float y = worldPos.y;
float z = worldPos.z;
float beamx = this.transform.position.x;//* 15.0f;
float beamy = this.transform.position.y;// * 15.0f;
float beamz = this.transform.position.z;// * 15.0f;
float distance = Vector3.Distance(new Vector3(x, y, 1), new Vector3(beamx, beamy, 1));
print (beamx+" "+beamy+" "+beamz + " Distance: "+distance+ " "+this.transform.localPosition+" "+worldPos);
transform.localScale = new Vector3(distance/transform.parent.transform.localScale.x, 1.0f/transform.parent.transform.localScale.y, 1.0f/transform.parent.transform.localScale.z);
this.transform.position = transform.parent.position;
//insert code to reposition the line so it looks like it is only increasing in size only on one end
}

Perhaps my question wasn't clear, but if I increase the size by X it extends the line on both left and right side. I want the line to appear as if it is only getting bigger on one side while at the same time maintaining its position pointed towards the mouse cursor.
– Stone-LegionThanks, I've done as you suggested but here are the problems that occur still. It is just odd behaviour, I cant tell if its simply because Unity 4.3 2D is causing problems or not. Maybe it's also because I haven't slept in 30 hours. Here's a pic of the issue. You can see now the line draws to the mouse, the mid way point on the transform is half way between the character and mouse, but the other end of the line just goes off into space oddly. http://imgur.com/hwBoC2X
– Stone-Legionpublic void UpdateLine(Transform linePrefab, Vector3 from, Vector3 to, float lineWidth, Vector3 toTarget) { Vector3 distance= to - from; transform.position = from + (distance/ 2f); transform.localScale = new Vector3(distance.magnitude/5.43f, lineWidth, 1f); } I've got it with this code. Why do you think that dividing by 5 would make it align nearly perfectly and work? I didn't use transform.right = toTarget.normalized; because it kept causing the line to rotate and throwing off the 2d collider.
– Stone-Legion