setting "x" scale to match distance of mouse drag

hey all, im working on a script that allows me to drag out away from a object, the further the distance the player drags, the more power will be used to fire the object forward. what im now trying to do is create an arrow that spawns as the player clicks down and scales out on the x axis as the player drags outward.

so far i have tried this but im getting this error :

Cannot modify a value type return value of `UnityEngine.Transform.localScale’. Consider storing the value in a temporary variable
Instantiate(ArrowPrefab,transform.position, Quaternion.identity);

       ArrowPrefab.transform.localScale.x = dragDistance;

any helps with this would be great

Here is precisely and exactly the full answer to your question:

please “thumb” it up (vote) on that page. Cheers


REGARDING YOUR C# ERROR.

You have to make “another” variable to change it.

Vector3 temp = ArrowPrefab.transform.localScale;
temp.x = dragDistance;
ArrowPrefab.transform.localScale = temp;

OK? that’s just how c# works, you have to make a temp variable for Vector3.

You can see in the doco that “localScale” is a Vector3.