need help making object scale to match distance

hey guys, im trying to spawn an object that continues to scale on one axis to match a distance between 2 points. now i know the calculation of the distance works fine as ive found out with debug. my issue is when the object spawns it does have the right value on the x axis, however as the distance gets larger the spawned object stays the same, what i want is the object to get larger every frame as the distance gets larger. also a 2nd issue is the object is pawning with values of 0 on both y and z axis, where i needed them on at least a scale of 1, i cant figure out why =S

here is the small bit of code (lines 194 to 203) which is my update section

void Update()
{
Debug.Log (dragDistance);
Vector3 temp = ArrowPrefab.transform.localScale;

temp.z = dragDistance;

ArrowPrefab.transform.localScale = temp;

}
full code can be seen here>>> codeviewer.org

any help would be great. thankyou

A few things to start off with. You should use the code tags, they make it much easier to understand what we’re looking at. Why exactly do you need the arrow to get larger as it goes off into the distance?

The reason the arrow prefab is spawning at 0 is this line of code. It’s going to instantiate it at the position of the object the script is run on.

Instantiate(ArrowPrefab,transform.position, Quaternion.identity);

If you want to make the arrow prefab spawn at 1,1,1 use this.

Instantiate(ArrowPrefab, new Vector3 (1,1,1) , Quaternion.identity);

thankyou for your reply, its not the position it spawns that gets me, its the scale, i want it to essentially stretch out as i drag the mouse away from a ball, which is where the arrow spawns.
an example of what im trying to achieve can be seen here,

i want an arrow to spawn as i hold down the mouse and drag back, like on the video

There’s nothing wrong with your code for stretching the object, unless the distance isn’t getting greater. Perhaps try a small project with just the arrow and play around with it.

Try this.

//maxArrowSize is the largest the arrow will grow.
//maxDragDistance is the distance at which the arrow will grow no more.
ArrowPrefab.transform.localScale = (maxArrowSize*(dragDistance/maxDragDistance));

I don’t do anything to stop dragDistance from getting larger than maxDragDistance here but that’s not to difficult to do.

thats just it, i dont get it, the distance goes up and down no problem but the object just doesnt scale in real time

I did a little experiment with the same code and it worked fine. I just moved up the z with z++. Build a model.

Wait it works on yours??? Did you edit the code at all?

I just did a little cube with your update code. It stretches out like it should. Try it. Take things in smaller steps.

ive just tried this with no luck still =[, did you use the full code of just the update bit? if so what did you use to get the drag distance?