- Home /
Scaling circle sprite x and y with distance value
Hello everyone, I hope you are all fine and appreciate unity answer forum for every solution of problem. I'm making unity board game like carom friends board game. I'm stuck in scaling of circle sprite position to mouse cursor position. Actually, when I set the distance value to x and y scale of circle sprite, it is not on the position of cursor. However, it made smaller circle while I want to extend it from circle position to cursor position. Appreciate if any help.
var circle = this.transform.Find("circle");
var circleTrans = circle.transform;
var distance = Vector3.Distance(mousePos, circleTrans.position);
distance = Mathf.Clamp(distance, 1, 3.1f);
circle.transform.localScale = new Vector3(distance, distance, circleTrans.localScale.z);
The above code is given which is included in the mousedrag function of parent object whose circle sprite is made a child. Thanks, if it is there any help for me.
Your answer
Follow this Question
Related Questions
smooth scailing (gui title image) 0 Answers
Why is my tree so gigantic? 2 Answers
Scaling my background Sprite to fill screen? (2d) 2 Answers
Scaling Issue while importing fbx from max 0 Answers
Why is my sprite resizing in the animation screen? 0 Answers